码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 关于页面跳转和传值

时间:2015-01-15 17:57:01      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

iOS 页面间的跳转目前有3种方式:

1、利用StroyBorad

这里以TableView的静态cell为例,选中第一个cell按住ctrl往新的ViewController上拖,弹出对话框选择show或present modally

技术分享

2、代码跳转

- (IBAction)Push:(id)sender {

    CATransition *animation = [CATransition animation];

    [animation setDuration:0.3];

    [animation setType: kCATransitionMoveIn];

    [animation setSubtype: kCATransitionFromTop];

    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];

    UIStoryboard * mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

    PresentViewController * info = [mainStoryboard instantiateViewControllerWithIdentifier:@"PresentViewController"];

    

    [self.navigationController pushViewController:info animated:NO];

    [self.navigationController.view.layer addAnimation:animation forKey:@"1"];

}

这是navigationController的push 有默认的返回

- (IBAction)presentView:(id)sender {

    UIStoryboard * mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

    PresentViewController * info = [mainStoryboard instantiateViewControllerWithIdentifier:@"PresentViewController"];

    

    self.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

    [self presentViewController:info animated:YES completion:^{

    }];

}

这是弹出模态框。调用

    [self dismissViewControllerAnimated:YES completion:^{

    }];返回上个界面

 

3、Seque跳转

这个方式要设定Seque的identifier进行动态绑定加载。选定源控制器的Controller技术分享

按住ctrl拖到要显示的Controller上,在弹出框上选择弹出类型。修改这个Seque的identifier=PushCtrl

修改代码:

[self performSegueWithIdentifier:@"PushCtrl" sender:self]; 这样就会跳转到这个identifier指定的页面上。

 

关于show,present modally可以参考官方文档 https://developer.apple.com/library/ios/recipes/xcode_help-IB_storyboard/chapters/StoryboardSegue.html

 

iOS 关于页面跳转和传值

标签:

原文地址:http://www.cnblogs.com/HypeCheng/p/4226500.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!