在我的iOS应用中,我使用
...
[self presentViewController:vc animated:YES completion:nil];
...
现在,在我的表格视图中点击一行之后,我想关闭我的表格视图控制器:
#pragma mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self dismissViewControllerAnimated:true completion:^(void) {
NSLog(@"dismissed");
}];
}
现在我的问题是:dismissViewControllerAnimated可以按预期工作,但是我必须点击该行2次。我第一次点击该行没有任何反应。
到目前为止的观察结果:
似乎即使我只敲击一次,完成块也会被“安排”。但是,解雇并没有发生。
有谁知道是什么原因造成了这个问题?
感谢par和ShahiM,我找到了解决方案:我不得不在主线程上解雇。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSelectorOnMainThread:@selector(dismissAndshowPdf) withObject:nil waitUntilDone:NO];
}
- (void) dismissAndshowPdf {
[self.presentingViewController dismissViewControllerAnimated:true completion:^(void) {
NSLog(@"dismissed");
}];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句