【发布时间】:2012-09-24 12:37:52
【问题描述】:
我有一个表格,其中包含来自 plist 文件的大量内容列表,单击其中的每一个都会将您带到一个新视图,即 xib。
我在 .xib 中有 2 个视图,一个用于纵向,一个用于横向
在我的 h 文件中,我有这个:
IBOutlet UIView *portraitView;
IBOutlet UIView *landscapeView;
@property (nonatomic, retain) IBOutlet UIView *portraitView;
@property (nonatomic, retain) IBOutlet UIView *landscapeView;
在我的 m 文件中:
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
}
- (void) orientationChanged:(id)object
{
UIInterfaceOrientation interfaceOrientation = [[object object] orientation];
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view = self.portraitView;
}
else
{
self.view = self.landscapeView;
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
self.view = portraitView;
} else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
self.view = landscapeView;
}
return YES;
}
@end
在 iOS 5 中一切正常,在需要时显示横向或纵向。
现在随着 iOS 6 的更新,一切都变得一团糟。
如果我在表格(纵向)视图中并单击一个项目,它会以纵向显示正确,如果我旋转到横向,则视图也会显示正确的视图,但是如果我回到表并选择另一个项目,它会显示纵向视图而不是横向视图。
如果我做同样的事情但从横向开始,它会显示纵向。
所以,现在方向对任何事情都不起作用。
我使用故事板的其他视图也是如此。它们是纵向的并且总是这样显示,现在它们会旋转、缩小所有内容并将我的应用程序作为垃圾。
1- 如何修复 .xib 方向的问题?
2-如何修复故事板方向? (它们是静态的,现在一切都在旋转(根本没有代码))
谢谢。
【问题讨论】:
标签: ios6 device-orientation xcode4.5