zoukankan      html  css  js  c++  java
  • UI基础 视图控制器

    RootViewController

    #import "RootViewController.h"
    #import "SecondViewController.h"
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        NSLog(@"视图已经加载好了,可以用了");
        self.view.backgroundColor=[UIColor redColor];
        UIButton* button=[UIButton buttonWithType:UIButtonTypeSystem];
        button.frame=CGRectMake(10, 100, 100, 50);
        [self.view addSubview:button];
        button.backgroundColor=[UIColor yellowColor];
        [button addTarget:self action:@selector(jump) forControlEvents:UIControlEventTouchUpInside];
        
        
    }
    -(void)jump
    {
    //    点击按钮到第二个页面
    //    跳到哪
        SecondViewController* second=[[SecondViewController alloc]init];
        
    //    怎么跳
        second.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
    //
        [self presentViewController:second animated:YES completion:^{
            NSLog(@"跳转完成");
        }];
        
        
        
    }
    
    -(void)loadView
    {
        
        [super loadView];
        NSLog(@"视图正在加载");
        
    }
    
    
    -(void)viewWillAppear:(BOOL)animated
    {
        
        NSLog(@"视图将要出现");
        
    }
    
    -(void)viewDidAppear:(BOOL)animated
    {
        NSLog(@"视图已经出现");
        
    }
    
    -(void)viewWillDisappear:(BOOL)animated
    {
        NSLog(@"视图将要消失");
        
    }
    -(void)viewDidDisappear:(BOOL)animated
    {
        NSLog(@"视图已经消失");
    }
    
    
    
    
    @end

    SecondViewController

    #import "SecondViewController.h"
    
    @interface SecondViewController ()
    
    @end
    
    @implementation SecondViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor=[UIColor blueColor];
        
        UIButton* button=[UIButton buttonWithType:UIButtonTypeSystem];
        button.frame=CGRectMake(10, 100, 100, 50);
        [self.view addSubview:button];
        button.backgroundColor=[UIColor yellowColor];
        [button addTarget:self action:@selector(jumpback) forControlEvents:UIControlEventTouchUpInside];
        
        
        
    }
    
    -(void)jumpback
    {
        
        [self dismissViewControllerAnimated:YES completion:^{
            NSLog(@"返回完成");
        }];
    }
    
    @end
  • 相关阅读:
    hadoop的文件系统FileSystem
    关于hadoop的日志
    top命令的使用
    对于多个集合求两两交集(共同关注的用户、共同转载的微薄等)
    hadoop配置含义(继续更新中)
    thrift
    【VS2015】Win7 X64上面安装VS2015
    【经验记录】开发中的实际问题记录
    【VS2012】F5不能自动编译新修改
    斯巴达三百程序员
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13348167.html
Copyright © 2011-2022 走看看