UIViewController
来源:互联网 发布:国泰君安软件 编辑:程序博客网 时间:2024/05/22 05:07
说明:
是视图控制器,控制多界面之间的相互切换,同时视图控制器中的View用于显示UI界面。
MainViewController* mvc = [[MainViewController alloc] init];self.window.rootViewController = mvc; //设置视图控制器为主视图控制器(这样可能会导致裁减视图,比如丢失上面20像素)[mvc release];-(void)viewDidLoad{ [super viewDidload];self.view.backgroundColor = [UIColor orangeColor];UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btn setTitle:@"模式对话框跳转" forState:UIControlStateNormal];[btn addTarget:self action:@selector(btnClick) forControlEvents: UIControlEventTouchUpInside];[self.view addSubView:btn];}-(void)btnClick //跳转{ SubViewController* svc = [[SubViewController alloc] init];svc.modalTransitionStyle = UIModelTransitionStyleFlipHorizontal; //设置用翻转的方式进行跳转 [self presentViewController:svc animated:YES completion:^{}]; //视图跳转核心代码 [svc release];}-(void)viewDidUnload{ self.view.backgroundColor = [UIColor greenColor];;}-(void)benClick//另一个视图的按钮跳转:{ [self dismissViewControllerAnimated:YES completion:^{}]; //关闭模式对话窗体}
总结:核心之处在于:一旦我设置好主控制器后,那么第一个呈现的界面就将会是这个主视图控制器,而且在这个主视图控制器里面可以控制视图的跳转等功能.
另外一个比较关键的地方是:[self dismissViewControllerAnimated:YES completion:^{}];
这种方式来关闭当前界面,而不是通过新建一个.将新建的设为当前视图的方式回到主界面.
0 0
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- UIViewController
- C++ primer(第五版) 练习 3.44 个人code
- UIImage UIImageView
- PDF转SWF
- Javascript模块化编程(三):require.js的用法
- 学生收费系统错误集合
- UIViewController
- Ajax—初识
- coco2d-js demo程序之滚动的小球
- UINavigationController
- java经典面试题(JAVA基础部分)
- linux 命令积累
- Go 语言编程
- 指针与引用的区别
- 海量数据处理分析