UIViewController

// 系统要进行初始化
- (void)loadView {
    [super loadView];
    NSLog(@"%s",__func__);
}
// 进一步初始化界面
- (void)viewDidLoad {
    NSLog(@"%s",__func__);
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    // self         用来调用控制部分的功能
    // self.view    用来调用视图部分的功能
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button1.frame  = CGRectMake(10, 100, 300, 30);
    button1.tag = 101;
    button1.backgroundColor = [UIColor cyanColor];
    [button1 addTarget: self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    // 加到视图控制器的视图上
    [self.view addSubview:button1];
    
        NSLog(@"%.1f %.1f",self.view.frame.origin.x,self.view.frame.origin.y);
        NSLog(@"%.1f %.1f",self.view.frame.size.width,self.view.frame.size.height);
    
//    NSString *path = [NSString stringWithFormat:@"%@/Library/Caches/demo.plist",NSHomeDirectory()];
//    NSLog(@"%@",NSHomeDirectory());
    
    
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"%s",__func__);
}
// 视图已经显示在屏幕上时调用
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"%s",__func__);
}


- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    NSLog(@"%s",__func__);
}
// 视图已经出屏幕时调用
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    NSLog(@"%s",__func__);
}



//- (void)viewDidUnload {
//    [super viewDidUnload];
//    NSLog(@"%s",__func__);
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - button Action
- (void)buttonAction:(UIButton *)button {
    NSLog(@"button %ld is clicked",button.tag);
    /**
     *  视图控制器跳转
     *  
     *  MainVC - > SecondVC
     */
    
    // 1. 实例化要跳转的界面对象
    SecondViewController *secondVC = [[SecondViewController alloc] init];
    
    // 1.5 设置模式
//    UIModalTransitionStyleCrossDissolve 渐变
//    UIModalTransitionStyleFlipHorizontal 横向翻转
//    UIModalTransitionStylePartialCurl   翻书
    secondVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    // 2.进行模式对话窗体跳转
    [self presentViewController:secondVC animated:YES completion:^{
        // 当跳转动画完成时的回调
        NSLog(@"跳转完成");
        
        
        NSLog(@"%.1f %.1f",self.view.frame.origin.x,self.view.frame.origin.y);
        NSLog(@"%.1f %.1f",self.view.frame.size.width,self.view.frame.size.height);
    }];
    
    
    
}

// 两加载
//- (void)loadView;
//- (void)viewDidLoad;
// 两进
//- (void)viewWillAppear:(BOOL)animated;
//- (void)viewDidAppear:(BOOL)animated;
// 两出
//- (void)viewWillDisappear:(BOOL)animated;
//- (void)viewDidDisappear:(BOOL)animated;
// 两释放
//- (void)viewWillUnload;
//- (void)didReceiveMemoryWarning;<pre name="code" class="objc">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    /**
        视图控制器  UIView + UIResponder
        有 视图部分 和 控制部分 两方面组成
        
        MVC - Model View Controller
        通过控制部分将数据模型绑定在视图上
     
        低耦合度 关联小 条理清晰
     */
    MainViewController *mainVC = [[MainViewController alloc] init];
    // 根视图控制器 rootVC 第一个显示的叫做根视图控制器
    self.window.rootViewController = mainVC;
    return YES;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值