【发布时间】:2010-12-10 10:28:28
【问题描述】:
我最近编写了一个类,它从一个表格单元中呈现一个自定义的 uiactionsheet,在这个 actionsheet 中是一个选择器视图和一个工具栏。当按下工具栏上的完成按钮时,将发送带有所选pickerview 值的通知,并且操作表被关闭。有时,当按下完成按钮时,动作表会从视图中消失,但该动作表的模态属性似乎仍然无法在出现的视图上选择任何内容。移动到另一个选项卡并返回似乎可以解决这个问题。有谁知道是什么原因造成的?
以下是我用来关闭操作表的代码:
-(void)doneButtonPressed:(id)sender{
if ([[self viewWithTag:1] isKindOfClass:[PickerView class]]) {
PickerView *picker = (PickerView *)[self viewWithTag:1];
if (picker.selectedRow == nil) {
[picker populateSelectRowForRow:0 andComponent:0];
}
NSNotification *note = [NSNotification notificationWithName:@"doneButtonPressed" object:self.indexPath userInfo:picker.selectedRow];
[[NSNotificationCenter defaultCenter] postNotification:note];
}else {
DatePickerView *picker = (DatePickerView *)[self viewWithTag:1];
NSDictionary *extraInfo = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] initWithObjects:[self formatDateToString:[picker date]], nil] forKeys:[[NSArray alloc] initWithObjects:@"value", nil]];
NSNotification *note = [NSNotification notificationWithName:@"doneButtonPressed" object:self.indexPath userInfo:extraInfo];
[[NSNotificationCenter defaultCenter] postNotification:note];
}
[self dismissWithClickedButtonIndex:0 animated:YES];
}
以及被调用的通知方法:
-(void)pickerUpdate:(NSNotification *)note{
NSIndexPath *indexPath = [note object];
NSDictionary *extraInfo = [note userInfo];
NSDictionary *dict = [[tableController.sectionAndFields objectAtIndex:indexPath.section] objectAtIndex:(indexPath.row + kHeaderAndFooterOffset)];
[tableController.formDetails setObject:[extraInfo objectForKey:@"value"] forKey:[dict objectForKey:@"key"]];
NSArray *reloadArray = [[NSArray alloc] initWithObjects:indexPath, nil];
[indexPath release];
[self.tv reloadRowsAtIndexPaths:reloadArray withRowAnimation:NO];
[reloadArray release];
}
感谢您花时间阅读这篇相当长的帖子, 会
【问题讨论】:
-
-reloadRowsAtIndexPaths:withRowAnimation:的第二个参数不是BOOL;这是一个UITableViewRowAnimation类型
标签: objective-c notifications reload uiactionsheet modalviewcontroller