【发布时间】:2011-07-14 06:35:30
【问题描述】:
更新:我找到了为什么它一直在加载相同的视图。我现在解决了这个问题。打错字了
ControllerForSplitViews.m
- (id)init
{
self = [super initWithNibName:@"ControllerForSplitViews" bundle:nil];
if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){
self.view = landscapeView;
}
if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation)){
self.view = portraintView;
}
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
return self;
}
这行得通。
现在的问题。当视图加载并运行时,我更改了方向并从同一个 nib 文件加载不同的视图,已修复:但是一旦我这样做,其他 UI 元素就会消失,只有我的横向视图的 ui 元素被保留,当我再次旋转设备它不会再次加载我的纵向视图?有什么建议为什么会发生这种情况?
-(void) orientationChanged:(id)object
{
if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
{
self.view = portraintView;
}
if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
{
self.view = landscapeView;
}
}
新问题,每次我改变方向时,它都会加载相反方向的视图
谢谢
【问题讨论】:
标签: ios objective-c ipad orientation