博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
新浪微博客户端(10)-切换多个fragment
阅读量:4705 次
发布时间:2019-06-10

本文共 1753 字,大约阅读时间需要 5 分钟。

 

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

 

最终效果:

 

转载于:https://www.cnblogs.com/yongdaimi/p/5988131.html

你可能感兴趣的文章
【翻译】Delphi中类的逆向工程
查看>>
我的Cocos2d-x学习笔记(二)AppDelegate补充介绍
查看>>
java获取中文拼音首字母工具类
查看>>
HDU 1729 Stone Game【SG函数】
查看>>
如何使用Vue实现拖拽效果pageY、screenY、clientY、layerY、offsetY(转)
查看>>
[Bzoj1009][HNOI2008]GT考试(KMP)(矩乘优化DP)
查看>>
由于无法验证发布者 所以windows阻止此软件
查看>>
又是一道水的逆向思维题
查看>>
Linux内核分析— —操作系统是如何工作的(20135213林涵锦)
查看>>
圆角效果
查看>>
还原AdventureWorks2008示例数据库遇到的问题
查看>>
Java学习笔记--集合
查看>>
控件置顶[置顶] Android常用UI控件之ProgressBar
查看>>
FPGA 相同模块 VIVADO synthesis综合后
查看>>
Python 常用库(随时补充)
查看>>
android中如何获取xml界面里的非自定义属性
查看>>
vmware错误汇总
查看>>
[转载]H3C S3600 DHCP-SERVER 配置【原创】
查看>>
创建一个名为User的类
查看>>
Java Web-----JSP与Servlet(一)
查看>>