这是我一直在努力的一个棘手的问题。我有一个动作表,显示在带有tabbar的视图中,有时当我关闭动作表时,它会被标签栏“抓住”并且无法执行任何操作。应用程序不会崩溃,因为如果我最小化它然后回来它是昏暗的,只是看起来模态行为没有被正确解雇。
我最近更改了操作表从“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];
}
答案 0 :(得分:0)
我确实设法解决了这个问题,但感觉非常像黑客,我在代码中引入了延迟:
[self performSelector:@selector(dismissFromActionSheet) withObject:nil afterDelay:0.2];
dismissFromActionSheet为:
-(void)dismissFromActionSheet{
[self dismissWithClickedButtonIndex:0 animated:YES];
}