zoukankan      html  css  js  c++  java
  • 新浪微博客户端(10)-切换多个fragment

    ViewController.m

    #import "ViewController.h"
    #import "DJOneViewController.h"
    #import "DJTwoViewController.h"
    #import "DJThreeViewController.h"
    
    
    @interface ViewController ()
    
    @property (nonatomic,strong) DJOneViewController *vc1;
    @property (nonatomic,strong) DJTwoViewController *vc2;
    @property (nonatomic,strong) DJThreeViewController *vc3;
    
    
    - (IBAction)btn1Click;
    
    - (IBAction)btn2Click;
    
    - (IBAction)btn3Click;
    
    
    @end
    
    @implementation ViewController
    
    
    
    - (DJOneViewController *)vc1 {
    
        if (!_vc1) {
            DJOneViewController *vc = [[DJOneViewController alloc] init];
            vc.view.frame = CGRectMake(60, 0, 600, 300);
            self.vc1 = vc;
        }
        return _vc1;
    }
    
    
    - (DJTwoViewController *)vc2 {
    
        if (!_vc2) {
            DJTwoViewController *vc = [[DJTwoViewController alloc] init];
            vc.view.frame = CGRectMake(60, 0, 600, 320);
            self.vc2 = vc;
        }
        return _vc2;
    
    }
    
    - (DJThreeViewController *)vc3 {
    
        if (!_vc3) {
            DJThreeViewController *vc = [[DJThreeViewController alloc] init];
            vc.view.frame = CGRectMake(60, 0, 600, 320);
            self.vc3 = vc;
        }
        return _vc3;
    }
    
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    - (IBAction)btn1Click {
    
        [self.vc2.view removeFromSuperview];
        [self.vc3.view removeFromSuperview];
        
        [self.view addSubview:self.vc1.view];
    }
    
    - (IBAction)btn2Click {
    
        [self.vc1.view removeFromSuperview];
        [self.vc3.view removeFromSuperview];
        [self.view addSubview:self.vc2.view];
        
        
    }
    
    - (IBAction)btn3Click {
        [self.vc1.view removeFromSuperview];
        [self.vc2.view removeFromSuperview];
        [self.view addSubview:self.vc3.view];
    }
    @end

    最终效果:

  • 相关阅读:
    四、元数据ParameterMetaData
    三、PreparedStatement对象(重点)
    二、properties文件存储信息
    一、JDBC3.0标准中常用接口与类
    十一、MySQL 数据库存储引擎介绍
    十、执行计划
    注册表中一些项目拒绝访问,拒绝更改权限,拒绝删除
    x64dbg 的条件断点及断点日志
    手机APP无法抓包HTTPS解决方案
    原版黑苹果安装(个人备忘)
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/5988131.html
Copyright © 2011-2022 走看看