标签:style class blog code http ext
使用Segue能够在ViewController之间来回切换,以下就来说下切换方法:
1. 使用点击button进行切换
直接上图,在须要切换的View属性界面,点击Modal然后拉到前一个view界面或者是Button上
2. 手动进行跳转
假设拉到了Button的TouchUpInside上,那么点击左側button的时候就会切到右边的View,假设拉到了view上,就会连接Manual,在代码中实现跳转
设置Segue的Indentifier属性:
代码中手动进行跳转:
//在viewDidAppear里面加入触发segue进行自己主动跳转
-(void)viewDidAppear:(BOOL)animated
{
[self performSegueWithIdentifier:@"drawecg" sender:self];
}3. 怎样跳转到随意一个页面
在有可能进行上级跳转的ViewController文件里加上以下代码,函数名称任起:
#pragma mark 定义这个函数,别的ViewController在Exit的时候就能直接跳到这了
- (IBAction)goHome:(UIStoryboardSegue *)segue
{
[[segue sourceViewController] class];
}
也可代码实现返回上一个页面,注销当前页面:
-(void)lastPage
{
NSLog(@"点击了上一个视图button");
[self dismissViewControllerAnimated:YES completion:^(void){
// Code
}];
}
也可这样实现:
// 获取故事板 UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; // 获取故事板中某个View UIViewController *next = [board instantiateViewControllerWithIdentifier:@"Second"]; // 跳转 [self presentModalViewController:next animated:YES];
跳转到LandscapeViewController
//打开一个横屏界面
- (IBAction)openLandscapeControl:(id)sender {
LandscapeViewController *control = [[LandscapeViewController alloc]initWithNibName:@"LandscapeViewController" bundle:nil];
[self.navigationController pushViewController:control animated:YES];
}使用pop返回上一个View//返回前一页
- (IBAction)clickBack:(id)sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}
IOS开发之——使用Segue在StoryBoard之间切换,布布扣,bubuko.com
IOS开发之——使用Segue在StoryBoard之间切换
标签:style class blog code http ext
原文地址:http://www.cnblogs.com/mengfanrong/p/3782630.html