16.1、UIViewController模式窗口跳转-OC+UI
2014-03-26 14:46
218 查看
UIViewController-1:
UIViewController 介绍:
UIViewController 模式对话窗口跳转:
(1)创建一个继承于UIViewController类
(2)
UIViewController 介绍:
UIViewController 模式对话窗口跳转:
(1)创建一个继承于UIViewController类
(2)
#import "ccyViewController.h" #import "childViewController.h" @interface ccyViewController () @end @implementation ccyViewController - (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. //设置视图控制器颜色 self.view.backgroundColor = [UIColor orangeColor]; //视图控制器的位置 NSLog(@"x = %f",self.view.frame.origin.x); NSLog(@"y = %f",self.view.frame.origin.y); NSLog(@"w = %f",self.view.frame.size.width); NSLog(@"h = %f",self.view.frame.size.height); /* x = 0.000000 y = 20.000000 - 视图控制器 不包括 状态栏的视图 w = 320.000000 h = 460.000000 */ //视图跳转 UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(10, 30, 300, 30); [btn setTitle:@"视图控制窗口切换" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; } - (void)btnClick { //每次按下会新建一个 childViewController * chvn = [[childViewController alloc] init]; //切换方式,默认是从下想上。 /* UIModalTransitionStyleCoverVertical = 0, - 默认 - 从下向上移动 UIModalTransitionStyleFlipHorizontal, - 横向翻转 UIModalTransitionStyleCrossDissolve, - 渐变cross UIModalTransitionStylePartialCurl, - 翻书 */ chvn.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentViewController:chvn animated:YES completion:^{ }]; [chvn release]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
#import "childViewController.h" #import "ccyViewController.h" @interface childViewController () @end @implementation childViewController - (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. self.view.backgroundColor = [UIColor greenColor]; //视图跳转 UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(10, 30, 300, 30); [btn setTitle:@"关闭模式对话窗口" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; } - (void)btnClick { //关闭模式对话窗口 [self dismissViewControllerAnimated:YES completion:^{ }]; //区别 [新增一个,这样多出来一个,并不是回到以前那个窗口,这个是错的] //ccyViewController * chvn = [[ccyViewController alloc] init]; //[self presentViewController:chvn animated:YES completion:^{ //}]; //[chvn release]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
#import "ccyAppDelegate.h" #import "ccyViewController.h"//增加头文件 @implementation ccyAppDelegate - (void)dealloc { [_window release]; [super dealloc]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. ccyViewController *cvm = [[ccyViewController alloc] init]; //这个是错误的,实际计数器加1是cvm.view,不是cvm //[self.window addSubview:cvm.view]; //[cvm release]; // 设置一个视图控制器为主视图控制器 [默认颜色 是透明] self.window.rootViewController = cvm; [cvm release]; self.window.backgroundColor = [UIColor redColor]; [self.window makeKeyAndVisible]; return YES; }
相关文章推荐
- 在模式窗口中实现页面跳转 .
- 在模式窗口中实现页面跳转
- 取消eclipse自动跳转到debug模式
- OC 单例模式
- 窗口模式与全屏模式切换,创建全屏窗口
- 模式字母窗口操作
- QMdiArea多个子窗口tabView模式去下划线
- android的窗口机制分析------UI管理系统
- js 模式窗口(模式对话框和非模式对话框)的使用介绍
- 【解决】showModalDialog模态窗口,使用JS跳转连接,IE弹出新窗口
- IntelliJ IDEA设置调试模式的Variables和Watches窗口的变量为Object模式
- 3、Info.plist文件介绍-OC+UI
- 第六篇 ANDROID窗口系统机制之显示机制--Bridge模式
- QT4+VS2008的窗口跳转(可扩展窗口之间信息传递)
- Javascript跳转页面和打开新窗口等方法
- 阻止模式窗口在提交时弹出新页面
- OC视频笔记-单例设计模式
- 黑马程序员---OC基础补充---补充:copy与mutableCopy、单例模式
- 模式窗口showModalDialog的用法总结
- JAVASCRIPT模式窗口中下载文件无法接收iframe的流