界面跳转
2016-03-14 21:27
323 查看
// MyFirstViewController.h
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MySecondViewControler.h"
@interface MyFirstViewController : UIViewController
@property(strong,nonatomic)UIButton *btn;
@end
// MyFirstViewController.m
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MyFirstViewController.h"
@interface MyFirstViewController ()
@end
@implementation MyFirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor blueColor];
self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
self.btn.frame=CGRectMake(100, 100, 100, 50);
self.btn.backgroundColor=[UIColor greenColor];
[self.btn addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.btn];
}
-(void)next
{
MySecondViewControler *mysec=[[MySecondViewControler alloc]init];
// 设置模态视图页面切换方式
mysec.modalTransitionStyle=3;
// 模态视图
[self presentViewController:mysec animated:YES completion:^{NSLog(@"页面切换完毕");}];
}
// MySecondViewControler.h
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MyThirdViewController.h"
@interface MySecondViewControler : UIViewController
@property(strong,nonatomic)UIButton *btn;
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MySecondViewControler.h"
@interface MySecondViewControler ()
@end
@implementation MySecondViewControler
- (void)viewDidLoad {
[super viewDidLoad];
self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
self.btn.frame=CGRectMake(100, 100, 100, 50);
self.btn.backgroundColor=[UIColor redColor];
[self.btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.btn];
self.view.backgroundColor=[UIColor greenColor];
}
-(void)back
{
//// 隐藏 返回上一页
// [self dismissViewControllerAnimated:YES completion:^{
// NSLog(@"front page show");
// }];
MyThirdViewController *mysec=[[MyThirdViewController alloc]init];
[self presentViewController:mysec animated:YES completion:^{NSLog(@"页面切换");}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// MyThirdViewController.h
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MyFirstViewController.h"
@interface MyThirdViewController : UIViewController
@property(strong,nonatomic)UIButton *btn;
@end
// MyThirdViewController.m
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MyThirdViewController.h"
@interface MyThirdViewController ()
@end
@implementation MyThirdViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor redColor];
// self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
// self.btn.frame=CGRectMake(100, 100, 100, 50);
// self.btn.backgroundColor=[UIColor greenColor];
// [self.btn addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside];
// [self.view addSubview:self.btn];
// Do any additional setup after loading the view.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[self presentViewController:[MyFirstViewController new] animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MySecondViewControler.h"
@interface MyFirstViewController : UIViewController
@property(strong,nonatomic)UIButton *btn;
@end
// MyFirstViewController.m
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MyFirstViewController.h"
@interface MyFirstViewController ()
@end
@implementation MyFirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor blueColor];
self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
self.btn.frame=CGRectMake(100, 100, 100, 50);
self.btn.backgroundColor=[UIColor greenColor];
[self.btn addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.btn];
}
-(void)next
{
MySecondViewControler *mysec=[[MySecondViewControler alloc]init];
// 设置模态视图页面切换方式
mysec.modalTransitionStyle=3;
// 模态视图
[self presentViewController:mysec animated:YES completion:^{NSLog(@"页面切换完毕");}];
}
// MySecondViewControler.h
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MyThirdViewController.h"
@interface MySecondViewControler : UIViewController
@property(strong,nonatomic)UIButton *btn;
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MySecondViewControler.h"
@interface MySecondViewControler ()
@end
@implementation MySecondViewControler
- (void)viewDidLoad {
[super viewDidLoad];
self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
self.btn.frame=CGRectMake(100, 100, 100, 50);
self.btn.backgroundColor=[UIColor redColor];
[self.btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.btn];
self.view.backgroundColor=[UIColor greenColor];
}
-(void)back
{
//// 隐藏 返回上一页
// [self dismissViewControllerAnimated:YES completion:^{
// NSLog(@"front page show");
// }];
MyThirdViewController *mysec=[[MyThirdViewController alloc]init];
[self presentViewController:mysec animated:YES completion:^{NSLog(@"页面切换");}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// MyThirdViewController.h
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MyFirstViewController.h"
@interface MyThirdViewController : UIViewController
@property(strong,nonatomic)UIButton *btn;
@end
// MyThirdViewController.m
// MyUI6-1
//
// Created by tlh on 16/3/14.
// Copyright © 2016年 lamco. All rights reserved.
//
#import "MyThirdViewController.h"
@interface MyThirdViewController ()
@end
@implementation MyThirdViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor redColor];
// self.btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
// self.btn.frame=CGRectMake(100, 100, 100, 50);
// self.btn.backgroundColor=[UIColor greenColor];
// [self.btn addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside];
// [self.view addSubview:self.btn];
// Do any additional setup after loading the view.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[self presentViewController:[MyFirstViewController new] animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
相关文章推荐
- 复制粘贴出来的悲剧----spring实现文件下载和HttpStatus.CREATED
- 图论相关算法理解和总结
- SpringMVC——注解的使用与结果跳转方式
- 自定义View实现正好显示文本
- 多年积累的对JAVA程序员成长之路的总结
- HDU1257 最少拦截系统[DP]
- maven 快照
- Android Fragment 替换覆盖生命周期方法详解
- ViewPager 详解(二)---详解四大函数
- 检测一段字符串是不是数字
- [BZOJ 1042][HAOI2008]硬币购物
- 整理spring零配置(Annotation)
- 修改C盘“用户”文件夹下面某个账户的文件夹名称
- Redis实现键对应多值
- C++第一次上机实验--(2)
- 本周的进度
- 写的一个UGUI下Image控件做序列帧动画的小工具
- UEFI+GPT安装Windows7系统
- spring-hibernate修改数据报错
- poj3250Bad Hair Day(单调栈)