zoukankan      html  css  js  c++  java
  • UI2_视图切换ViewController

    //
    //  SubViewController.h
    //  UI2_视图切换
    //
    //  Created by zhangxueming on 15/7/3.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface SubViewController : UIViewController
    
    @end
    
    
    //
    //  SubViewController.m
    //  UI2_视图切换
    //
    //  Created by zhangxueming on 15/7/3.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import "SubViewController.h"
    
    @interface SubViewController ()
    
    @end
    
    @implementation SubViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        self.view.backgroundColor = [UIColor cyanColor];
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
        btn.frame = CGRectMake(20, 300, self.view.frame.size.width-40, 50);
        btn.backgroundColor = [UIColor whiteColor];
        [btn setTitle:@"视图切换" forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btn];
    }
    
    - (void)btnClicked
    {
        NSLog(@"-----");
        if (self.view.superview) {
            [self.view removeFromSuperview];
        }
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    /*
    #pragma mark - Navigation
    
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        // Get the new view controller using [segue destinationViewController].
        // Pass the selected object to the new view controller.
    }
    */
    
    @end
    
    //
    //  RootViewController.h
    //  UI2_视图切换
    //
    //  Created by zhangxueming on 15/7/3.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface RootViewController : UIViewController
    
    @end
    
    
    //
    //  RootViewController.m
    //  UI2_视图切换
    //
    //  Created by zhangxueming on 15/7/3.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import "RootViewController.h"
    #import "SubViewController.h"
    
    @interface RootViewController ()
    {
        SubViewController *_svc;
    }
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        self.view.backgroundColor = [UIColor redColor];
        
        _svc = [[SubViewController alloc] init];
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
        btn.frame = CGRectMake(20, 200, self.view.frame.size.width-40, 50);
        [btn setTitle:@"视图切换" forState:UIControlStateNormal];
        btn.backgroundColor = [UIColor whiteColor];
        [btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btn];
    }
    
    - (void)btnClicked
    {
        [self.view addSubview:_svc.view];
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    /*
    #pragma mark - Navigation
    
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        // Get the new view controller using [segue destinationViewController].
        // Pass the selected object to the new view controller.
    }
    */
    
    @end
    
    //
    //  AppDelegate.m
    //  UI2_视图切换
    //
    //  Created by zhangxueming on 15/7/3.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import "AppDelegate.h"
    #import "RootViewController.h"
    
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        RootViewController *rootViewController = [[RootViewController alloc] init];
        self.window.rootViewController = rootViewController;
        return YES;
    }
    
  • 相关阅读:
    mount 和 umount 命令
    mmap函数使用
    Linux系统下查看目录大小
    守护进程的创建方法和步骤
    linux中的dup()系统调用
    uboot烧写命令--yaffs、jiffs和ubifs
    对volatile关键字的理解
    linux下如何挂接(mount)光盘镜像文件、移动硬盘、U盘、Windows网络共享和NFS网络共享
    常用NFS mount选项介绍
    mount nfs 经常出错信息总结(转)
  • 原文地址:https://www.cnblogs.com/0515offer/p/4638603.html
Copyright © 2011-2022 走看看