Cap*_*Jak 6 cocoa-touch objective-c storyboard uinavigationcontroller ios
我在这个网站上尝试了几个答案,但似乎没有一个与我的问题有关
我有一个MasterDetail应用程序,它有两种类型的segues我正在使用.当您按下详细视图上的按钮时,它会使用推送segue并将另一个详细视图推送到该视图上.在新的detailview(刚推入的那个)中,有一个按钮,它使用模态segue调用另一个UIView(表单).
我所试图做的是当用户选择一排,一个UIAlertView中会出现一个显示的消息,而在同一时间(不一定是在同一时间)解聘的UIViewController的(模式),并返回来自推动的Viewcontroller.基本上,我需要能够解雇所有的viewcontrollers,一个模态和一个push(nav),以便视图返回到他们开始的原始主屏幕.
我有UIAlertView工作正常,我可以通过使用,[self.dismissViewControllerAnimated:YES completion:nil];但我不知道如何解雇下一个Viewcontroller(在导航控制器中)解雇模态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
}
Run Code Online (Sandbox Code Playgroud)
Rob*_*Rob 14
如果需要,可以在iOS 6.0(及更高版本)项目中使用展开segue.例如,您可以:
在您的顶级视图控制器(一个你想放松来,而不是控制你要放松的),写一个开卷SEGUE方法,在这种情况下,所谓的unwindToTopLevel(个人而言,我觉得它非常有用,如果SEGUE负有一定指示至于segue的目的地是什么,原因在我们到达下面的第3步时会变得明显:):
- (IBAction)unwindToTopLevel:(UIStoryboardSegue *)segue
{
NSLog(@"%s", __FUNCTION__);
}
Run Code Online (Sandbox Code Playgroud)在将从中启动展开的Interface Builder场景中,control ⌘从视图控制器图标-drag到退出图标以创建展开segue:

通常,您将segue从按钮定义到出口(并且已完成),但如果要以编程方式调用segue,则可能需要在控制器和展开出口之间创建它,如上所示.
你会得到一个小小的弹出窗口,包括你展开的segues的名字(来自呈现的控制器...它就像魔术一样):

如果您要以编程方式调用segue,则必须在IB窗口左侧的文档大纲中选择展开segue,一旦完成,您可以为展开segue提供一个storyboard id:

我通常使用展开segue的名称作为故事板id,但你可以使用你想要的任何东西.
现在,完成后,您的警报视图可以调用segue:
- (IBAction)didTouchUpInsideButton:(id)sender
{
[[[UIAlertView alloc] initWithTitle:nil message:@"go home" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil] show];
}
#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex != [alertView cancelButtonIndex])
{
[self performSegueWithIdentifier:@"unwindToTopLevel" sender:self];
}
}
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
2740 次 |
| 最近记录: |