ios UIViewController
2013-11-22 15:09
351 查看
//UIViewController 模式跳转 ViewController *mvc = [[ViewController alloc]init]; [self.viewController presentViewController:mvc animated:YES completion:^{ }]; [mvc release]; //关闭模式对话框窗体,跳转回去。 [self.viewController dismissViewControllerAnimated:YES completion:^{ }]; //设置跳转方式 mvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; #import "ViewController.h" #import "SubViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)loadView { [super loadView]; UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(100, 30, 80, 40); [button setTitle:@"open modal" forState:UIControlStateNormal]; [button addTarget:self action:@selector(openModel) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; self.view.backgroundColor = [UIColor greenColor]; } - (void)openModel { //模式对话框跳转 SubViewController *sub = [[SubViewController alloc]init]; //设置跳转效果 // sub.modalTransitionStyle = UIModalTransitionStyleCoverVertical;//上下 // sub.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //左右反转 // sub.modalTransitionStyle = UIModalTransitionStylePartialCurl; //翻页 sub.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; //直接跳转 [self presentViewController:sub animated:YES completion:^{}]; [sub release]; } @end #import "SubViewController.h" @interface SubViewController () @end @implementation SubViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)loadView { [super loadView]; UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(100, 30, 80, 40); [button setTitle:@"close modal" forState:UIControlStateNormal]; [button addTarget:self action:@selector(closeModel) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; self.view.backgroundColor = [UIColor redColor]; } - (void)closeModel { [self dismissViewControllerAnimated:YES completion:^{}]; } @end
相关文章推荐
- iOS开发 - UIViewController控制器管理
- iOS_深入_UINavigationController VS UIViewController _利用分栏控制器切换视图
- iOS 5.0 后UIViewController新增:willMoveToParentViewController和didMoveToParentViewCon[转]
- iOS UIViewController API解读
- ios 触摸事件无法响应之UIViewController的误用
- UIViewController的生命周期及iOS程序执行顺序
- iOS 获取view的controller UIView+UIViewController
- iOS入门(二十七)视图控制器UIViewController
- IOS学习:在一个UIViewController中实现侧边菜单的思路及demo
- iOS 之UIViewController的生命周期
- iOS UIViewController 归类
- IOS UIViewController详解以及生命周期管理
- UIViewController的生命周期及iOS程序执行顺序
- iOS自定义转场详解01——UIViewControllerTransitioning的用法
- iOS6及之前版本的iOS中UIViewController的生命周期(Load及Unload简析)
- iOS 滑动分页控件, 可以把UIViewController加进来,当作某一页来展示
- iOS UIViewController之间的传值方式之一:委托代理
- iOS之UIViewController执行返回操作并传递参数值的两种方式
- 【iOS 1 行代码系列】之 一行代码解耦控制器UIViewController
- iOS:关于UIViewController的初始化