行动表未被驳回
我最近编写了一个类,它从表格单元格中呈现自定义 uiactionsheet,在此操作表中是一个选择器视图和一个工具栏。当按下工具栏上的完成按钮时,将发送带有所选选取器视图值的通知,并且操作表将被关闭。有时,当按下“完成”按钮时,操作表会从视图中消失,但该操作表的模态属性似乎仍然存在,因为我无法在出现的视图上选择任何内容。移动到另一个选项卡并返回似乎可以解决这个问题。有谁知道可能导致此问题的原因吗?
下面是我用来关闭操作表的代码:
-(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];
}
感谢您花时间阅读这篇相当长的文章, 将要
I've recently written a class that presents a custom uiactionsheet from a tablecell, in this actionsheet is a pickerview and a toolbar. When the done button on the toolbar is pressed a notifcation is sent with the choosen pickerview value and the actionsheet is dismissed. Sometimes the actionsheet vanishes from the view when the done button is pressed however it appears that the modal property of that actionsheet remains as am unable to select anything on the view that appears. Moving to another tab and coming back seems to solve this. Does anyone have any ideas what could be causing this?
Below is the code I use to dismiss my actionsheet:
-(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];
}
and the notification method that is called:
-(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];
}
Thanks for taking the time to read this rather long post,
Will
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,您应该使用 actionSheet: clickedButtonAtIndex 方法..
As far as i know, you should the actionSheet: clickedButtonAtIndex method..
我确实设法解决了这个问题,但感觉很像黑客,我使用
以下方法在代码中引入了延迟:
I did manage to solve this however it feels very much like a hack, I introduced a delay into the code using:
With dismissFromActionSheet being: