【发布时间】:2013-07-10 11:58:42
【问题描述】:
我在这个网站上尝试了一些答案,但似乎都与我的问题无关
我有一个 MasterDetail 应用程序,它有两种我正在使用的 segues。当您按下详细视图上的按钮时,它会使用 push segue 并将另一个详细视图推送到该按钮上。在新的 detailview(刚刚被按下的那个)中有一个按钮,它使用模态 segue 调用另一个 UIView(表单)。
我想要做的是当用户选择一行时,一个 UIAlertView 将显示一条消息,同时(不必在同时时间)它会解除 UIViewcontroller(模态)并从被推送的 Viewcontroller 返回。基本上,我需要能够关闭所有视图控制器、一个模式和一个推送(导航),以便视图返回到它们开始时的原始主屏幕。
我的 UIAlertView 工作正常,我可以使用 [self.dismissViewControllerAnimated:YES completion:nil]; 让模态视图控制器关闭,但我不知道如何关闭下一个 Viewcontroller(位于导航控制器中)。使用这个:[self.navigationController popToRootViewControllerAnimated:NO]; 不起作用。
这里是我要调用函数来删除所有视图的地方:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlWithIDAndChallenge];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
UIAlertView *message = [[UIAlertView alloc] initWithTitle@"Started" message:@"The challenge has begun!" delegate:nil cancelButtonTitle:@"OK!" otherButtonTitles:nil];
[message show]
//right here is where I would normally dismiss the modal VC
//here is where I would like to dismiss all VC
}
【问题讨论】:
-
您支持哪些 iOS 版本?如果只有 iOS 6 及更高版本,您可以使用 unwind segues,这样做非常优雅。
-
当我在您的问题中找到我的问题的答案时的那种感觉。非常感谢。
标签: ios objective-c cocoa-touch uinavigationcontroller storyboard