[英]Navigate back from UITabviewController to ViewController in storyboard
My hierarchy 我的阶层
UINavigationController -> UIViewController
-> UITabViewController
-> ViewController1
-> ViewController2
-> ViewController3
I want to navigate back from 我想从导航
ViewController1 -> UIViewController.
Anyone know please solve this issues. 任何人都知道,请解决此问题。
"Unwind" is your answer. “放松”是您的答案。
Create an IBAction
method to unwind segue. 创建一个IBAction
方法以解除锁定。 Define this method in a controller in which you want to unwind (Controller from you want to jump back to main controller). 在要展开的控制器中定义此方法(要从中跳回主控制器的控制器)。
- (IBAction) prepareForUnwind:(UIStoryboardSegue *)segue {
}
Now connect back button (in this case "Home" button) with this method in Storyboard. 现在,使用情节提要中的此方法连接后退按钮(在本例中为“主页”按钮)。 To connect unwind action -> Ctrl-drag to "Exit" outlet button of your controller. 要连接展开动作-> Ctrl拖动到控制器的“退出”出口按钮。
Note: If you are using Xcode version less than 6.0 than "Exit" outlet is located at bottom of your view controller. 注意:如果您使用的Xcode版本低于6.0,则“ Exit”出口位于视图控制器的底部。
This will navigate back to your root navigation controller. 这将导航回到您的根导航控制器。 That is UIViewController. 那就是UIViewController。
For further separation you can give an identifier to unwind segue and make different actions for exit to last controller. 为了进一步分离,您可以指定一个标识符以解除顺序并做出不同的动作以退出到最后一个控制器。
Select identifier from left list and give an identifier in Attributes inspector. 从左侧列表中选择标识符,然后在“属性”检查器中提供一个标识符。
Key points: 关键点:
You can use 您可以使用
[navigationController popToViewController:<#(UIViewController *)#> animated:<#(BOOL)#>];
just provide the instance of the viewController you want to pop to and set animated property to YES if u want pop with animation and NO if not. 只需提供要弹出到的viewController的实例,然后将动画属性设置为YES(如果您想弹出动画),否则设置为NO。
Here the controller UIViewController
is the rootViewController of UINavigationController
. 这里的控制器UIViewController
是UINavigationController
的rootViewController。 So you just need to pop to the rootViewController
from the ViewController1
所以你只需要从ViewController1
弹出到rootViewController
[self.navigationController popToRootViewControllerAnimated:YES];
You can done by this: 您可以这样做:
ViewController *loginVC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
[self.navigationController popToViewController: loginVC animated:YES]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.