【发布时间】:2010-12-09 16:44:11
【问题描述】:
这是一个我已经研究了一段时间的棘手问题。我有一个显示在带有选项卡栏的视图中的操作表,有时当我关闭操作表时,它会在选项卡栏中“捕获”并且无法执行任何操作。应用程序不会崩溃,因为如果我将其最小化然后回到它被驳回,它只是看起来模态行为没有被正确驳回。
我最近将操作表的显示方式从“showInView”更改为“showFromTabBar”,但不确定这是否会造成问题。
谢谢, 威廉
编辑:
以下是我用来关闭操作表的代码:
-(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 uiactionsheet tabbar