#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view1=[[UIView alloc]initWithFrame:CGRectMake(40, 40, 200, 100)];
self.view1.backgroundColor=[UIColor redColor];
self.view2=[[UIView alloc]initWithFrame:self.view1.frame];
self.view2.backgroundColor=[UIColor blueColor];
self.view3=[[UIView alloc]initWithFrame:self.view1.frame];
self.view3.backgroundColor=[UIColor greenColor];
UIView *containview=[[UIView alloc]initWithFrame:self.view1.frame];
[containview addSubview:self.view3];
[containview addSubview:self.view2];
[containview addSubview:self.view1];
[self.view addSubview:containview];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)transform:(UIButton *)sender { [UIView transitionFromView:self.view1 toView:self.view3 duration:2 options:UIViewAnimationOptionShowHideTransitionViews|UIViewAnimationOptionTransitionFlipFromLeft completion:nil];}
我想从第一个视图转换到第三个视图。但是运行却是第一个转换到第二个视图。能不能告诉我为什么。应该怎么修正代码。谢谢。
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view1=[[UIView alloc]initWithFrame:CGRectMake(40, 40, 200, 100)];
self.view1.backgroundColor=[UIColor redColor];
self.view2=[[UIView alloc]initWithFrame:self.view1.frame];
self.view2.backgroundColor=[UIColor blueColor];
self.view3=[[UIView alloc]initWithFrame:self.view1.frame];
self.view3.backgroundColor=[UIColor greenColor];
UIView *containview=[[UIView alloc]initWithFrame:self.view1.frame];
[containview addSubview:self.view3];
[containview addSubview:self.view2];
[containview addSubview:self.view1];
[self.view addSubview:containview];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)transform:(UIButton *)sender { [UIView transitionFromView:self.view1 toView:self.view3 duration:2 options:UIViewAnimationOptionShowHideTransitionViews|UIViewAnimationOptionTransitionFlipFromLeft completion:nil];}
我想从第一个视图转换到第三个视图。但是运行却是第一个转换到第二个视图。能不能告诉我为什么。应该怎么修正代码。谢谢。
解决方案 »
- iPhone接入分享到微信朋友圈求助
- Objact C语言?
- 新手求解两种NSString赋值的区别
- 请问如何通过手机获取的经纬度判断当前时区?
- 请教iPhone平台问题
- phonegap 3.3怎么安装
- drawRect中如何自定义UIView形状??我的代码有些问题
- swift网络请求http://bbs.csdn.net/topics/390804115
- 关于@interface和@implementation,求解!
- [求助]UICollectionView reloadData无法界面
- iphone sqlite3 怎么实现多线程访问?
- 关于UINavigationBar加载不规则的图片的总结
1. view2不要提前添加到视图层级上,只有当需要显示时才显示。或者你自己调整containview的子视图的视图层级
2. 把UIViewAnimationOptionShowHideTransitionViews替换为UIViewAnimationOptionLayoutSubviews,让系统去调整containview的子视图的视图层级