【发布时间】:2011-04-29 00:55:04
【问题描述】:
以下是我希望在我的应用程序中具有的两种布局。如果应用程序从纵向切换到横向时保留 UILabel、BOOL 和其他对象,那就太好了。因为按钮的位置不同,我不能只让纵向视图在自动旋转时自动调整大小。我还想使用 BOOL 和右上角的按钮来实现自己的旋转锁定。
我考虑过将 -(void)orientationChanged:(NSNotification )notification 与 presentModalViewController 一起使用,但是这些并没有复制对象并且似乎导致 @987654321 @。
感谢您的帮助!
尝试的解决方案:
我将横向视图添加到 ViewController,在视图控制器中具有两个视图。我将它链接到我在 ViewController 的@interface 部分中添加的 UIView *landscapeView 下的 File's Owner。我将 [self.view addSubview:landscapeView] 添加到 viewDidLoad 方法中。然后我添加了这段代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (orientationLock)
return NO;
else {
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
[landscapeView setHidden:YES];
//[self.view setHidden:NO]; removed
} else {
//[self.view setHidden:YES]; removed
[landscapeView setHidden:NO];
}
return YES;
}
}
但这不是正确的解决方案。当我运行模拟器并旋转它时,屏幕没有正确放置。
【问题讨论】:
标签: objective-c xcode ios4 rotation xib