[英]ios-How do I add a navigation controller to a project?
I have a project and I am having trouble maintaining a navigation controller (which I added through the interface builder). 我有一个项目,并且在维护导航控制器(通过接口构建器添加)时遇到了麻烦。 I want to set up a hierarchy because it is saying the views are not added to the window hierarchy. 我要建立一个层次结构,因为它是说视图未添加到窗口层次结构中。 I can move between one view using performSegueWithIdentifier, but using it a second time doesn't work. 我可以使用performSegueWithIdentifier在一个视图之间切换,但是第二次使用不起作用。 The problem is it won't allow me to move from one view to another. 问题是它不允许我从一种视图移动到另一种视图。 I have read stuff about messing with the appdelegate or add performForSegue, but I don't know how to using it. 我已经阅读过有关混淆appdelegate或添加performForSegue的内容,但是我不知道如何使用它。
Any suggestions for if I had three views connected like 1 -> 2 -> 3? 如果我有3个类似1-> 2-> 3的视图,有什么建议吗? 1 and 2 would have performSegueWithIdentifier. 1和2将具有performSegueWithIdentifier。
Please and thank you! 谢谢,麻烦您了!
Here is my storyboard: http://s1370.photobucket.com/user/sean_cleveland1/media/Untitled_zpsc9022523.png.html?o=0 这是我的故事板: http ://s1370.photobucket.com/user/sean_cleveland1/media/Untitled_zpsc9022523.png.html?o =0
Here is my performSegueWithIdentifier functions: 这是我的performSegueWithIdentifier函数:
//Used in FirstVC.
[self performSegueWithIdentifier: @"firstToSecond" sender: self];
//Used in SecondVC... this doesn't work!
[self performSegueWithIdentifier: @"secondToThird" sender: self];
Just Control + drag from "Pop to Main Screen" UIButton
to Exit (green button at bottom of scene) select unwind method declared in first screen with title "Main" eg 只需控制+从“ Pop to Main Screen” UIButton
拖动到退出(场景底部的绿色按钮),选择在第一个屏幕中声明为标题为“ Main”的展开方法,例如
-(IBAction)customUnwind:(UIStoryboardSegue *)sender
{
NSLog(@"Unwind successful");
}
First define your third view identifier 首先定义您的第三个视图标识符
- (void)segue
{
[self performSegueWithIdentifier:@"mySegue" sender:self];
}
for only do any condition or operation use below method 仅在任何条件或操作下使用以下方法
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:@"mySegue"]) {
}
}
i created simple sample project for you 我为您创建了一个简单的示例项目
https://github.com/iDevAndroid/NavigationSample https://github.com/iDevAndroid/NavigationSample
try with this. 试试这个。 because your are perform model transaction after next line your are using dismiss the model. 因为您在下一行之后执行模型事务,所以您正在使用以关闭模型。
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self becomeFirstResponder];
[self dismissViewControllerAnimated:YES completion:^{
[self emailDelivaryedSuccessfully];
];
}
-(void)emailDelivaryedSuccessfully{
[self performSegueWithIdentifier: @"secondToThird" sender: self];
}
You don't need to use performSegueWithIdentifier:
if you are doing it in Storyboard, just comment the code which says performSegueWithIdentifier:
and prepareForSegue:
method in your code and try. 您不需要使用performSegueWithIdentifier:
如果在Storyboard中进行操作,只需在代码中注释“ performSegueWithIdentifier:
和prepareForSegue:
方法的代码,然后尝试。 If you are using performSegueWithIdentifier:
then you need to implement prepareForSegue:
method also. 如果您正在使用performSegueWithIdentifier:
则还需要实现prepareForSegue:
方法。 ex. 恩。
[self performSegueWithIdentifier: @"firstToSecond" sender: self];
//prepareforsegue method // prepareforsegue方法
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:@"firstToSecond"]) {
SecondViewController *destinationController = [segue destinationViewController];
//set data if any
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.