三种ViewController跳转的异同
来源:互联网 发布:中银淘宝卡年费逾期 编辑:程序博客网 时间:2024/06/04 23:23
#import "ViewController.h"
#import "FirstVC.h"
#import "SecondVC.h"
#import "ThirdVC.h"
@interface ViewController ()
{
FirstVC *firstVC;
SecondVC *secondVC;
ThirdVC *thirdVC;
}
@property (weak, nonatomic) IBOutlet UIView *contentView;
@property (strong, nonatomic) UIViewController *currentVC;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
firstVC = [[FirstVC alloc] init];
secondVC = [[SecondVC alloc] init];
thirdVC = [[ThirdVC alloc] init];
[self addChildViewController:firstVC];
[self addChildViewController:secondVC];
[self addChildViewController:thirdVC];
[self.contentView addSubview:thirdVC.view];
self.currentVC = thirdVC;
}
- (IBAction)onClick:(id)sender {
if(self.currentVC==firstVC && [sender tag]==1) {
return;
}
if(self.currentVC==secondVC && [sender tag]==2) {
return;
}
if(self.currentVC==thirdVC && [sender tag]==3) {
return;
}
UIViewController *oldVC = self.currentVC;
switch ([sender tag]) {
case 1: {
[self transitionFromViewController:self.currentVC toViewController:firstVC duration:1 options:UIViewAnimationOptionTransitionCurlUp animations:^{
} completion:^(BOOL finished) {
if(finished) {
self.currentVC = firstVC;
}
else {
self.currentVC = oldVC;
}
}];
}
break;
case 2: {
[self transitionFromViewController:self.currentVC toViewController:secondVC duration:1 options:UIViewAnimationOptionTransitionCurlUp animations:^{
} completion:^(BOOL finished) {
if(finished) {
self.currentVC = secondVC;
}
else {
self.currentVC = oldVC;
}
}];
}
break;
case 3: {
[self transitionFromViewController:self.currentVC toViewController:thirdVC duration:1 options:UIViewAnimationOptionTransitionCurlUp animations:^{
} completion:^(BOOL finished) {
if(finished) {
self.currentVC = thirdVC;
}
else {
self.currentVC = oldVC;
}
}];
}
break;
default:
break;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
#import "FirstVC.h"
#import "SecondVC.h"
#import "ThirdVC.h"
@interface ViewController ()
{
FirstVC *firstVC;
SecondVC *secondVC;
ThirdVC *thirdVC;
}
@property (weak, nonatomic) IBOutlet UIView *contentView;
@property (strong, nonatomic) UIViewController *currentVC;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
firstVC = [[FirstVC alloc] init];
secondVC = [[SecondVC alloc] init];
thirdVC = [[ThirdVC alloc] init];
[self addChildViewController:firstVC];
[self addChildViewController:secondVC];
[self addChildViewController:thirdVC];
[self.contentView addSubview:thirdVC.view];
self.currentVC = thirdVC;
}
- (IBAction)onClick:(id)sender {
if(self.currentVC==firstVC && [sender tag]==1) {
return;
}
if(self.currentVC==secondVC && [sender tag]==2) {
return;
}
if(self.currentVC==thirdVC && [sender tag]==3) {
return;
}
UIViewController *oldVC = self.currentVC;
switch ([sender tag]) {
case 1: {
[self transitionFromViewController:self.currentVC toViewController:firstVC duration:1 options:UIViewAnimationOptionTransitionCurlUp animations:^{
} completion:^(BOOL finished) {
if(finished) {
self.currentVC = firstVC;
}
else {
self.currentVC = oldVC;
}
}];
}
break;
case 2: {
[self transitionFromViewController:self.currentVC toViewController:secondVC duration:1 options:UIViewAnimationOptionTransitionCurlUp animations:^{
} completion:^(BOOL finished) {
if(finished) {
self.currentVC = secondVC;
}
else {
self.currentVC = oldVC;
}
}];
}
break;
case 3: {
[self transitionFromViewController:self.currentVC toViewController:thirdVC duration:1 options:UIViewAnimationOptionTransitionCurlUp animations:^{
} completion:^(BOOL finished) {
if(finished) {
self.currentVC = thirdVC;
}
else {
self.currentVC = oldVC;
}
}];
}
break;
default:
break;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
0 0
- 三种ViewController跳转的异同
- 三种ViewController跳转的异同
- 三种ViewController跳转的异同
- 三种ViewController跳转的异同
- 三种ViewController跳转的异同
- 三种ViewController跳转的异同
- 三种ViewController跳转的异同
- ios学习笔记:三种ViewController跳转的异同
- 三种ViewController跳转的异同(两种转场动画的实现待总结)
- ViewController跳转的三种方式的混合使用
- viewController之间的跳转
- ViewController的页面跳转
- 慎用ViewController的跳转 (转)
- viewcontroller跳转的动画风格
- 跳转到指定的viewcontroller
- ViewController页面跳转的方法
- 23.创建ViewController的三种方式
- iOS ViewController跳转界面的几种方法简单总结
- 转场视图
- uvaoj-455:周期串
- Karma的第一次使用
- 范式理论
- Python 利用PIL将图片转为字符
- 三种ViewController跳转的异同
- swoole(一)
- 数据库三范式
- 改进版的冒泡排序(双向冒泡算法)
- 【官方】Android Studio中使用Git托管到GitHub
- 命令行模式下备份、还原 MySQL 数据库
- java 单链表实现栈
- Java设计模式(十五)----观察者模式
- 重构——存储过程返回值探索