【发布时间】:2012-07-12 16:24:53
【问题描述】:
我在 UIViewController 子类中有这段代码:
- (id)init {
self = [super init];
if (self) {
self.view.frame = [PDToolbox screenFrame];
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.view.backgroundColor = [UIColor redColor];
}
return self;
}
就任何旋转方法而言,我唯一拥有的是:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return YES;
}
然而在屏幕旋转到横向后,在视图上执行 NSLog 会显示:
<UIView: 0x10061640; frame = (0 0; 320 480); transform = [0, -1, 1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x10061670>>
我不明白它为什么要做这种变换,而不是像往常一样旋转?这意味着我在旋转后放置在其顶部并设置为视图大小的任何视图最终都位于 320x480 位置。
编辑:
人们不理解。所以我在它上面放了一个视图,大小和 UIView 一样,使用:
UIView *anotherView = [UIView alloc] initWithFrame:controller.view.bounds];
[controller.view addSubview:anotherView];
如果我以纵向添加另一个视图,则另一个视图以纵向显示,框架为 320x480。
如果我在横向中添加 anotherView,anotherView 会出现在横向中,但仍具有 320x480 的框架,因为出于某种未知原因,controller.view 的框架仍然如此。
【问题讨论】:
-
你能把你的 UIViewCONtroller 的完整代码贴出来吗
-
@RA 当然。刚刚完成。
-
其实我不明白你的问题..这是什么意思?“我在旋转后放置在它上面的视图并设置为视图的大小最终位于 320x480 位置”
-
您是直接将此视图添加到窗口中还是什么?这是一种非常奇怪的行为,通常由您的视图控制器层次结构(正确地)管理。
标签: iphone objective-c ios uiview rotation