更新:我发现了为什么它总是一直加载相同的视图。我现在解决了。这是一个错字

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;
    }
 }


新问题,每次更改方向时,都会加载相反方向的视图

谢谢

最佳答案

如果有人阅读过此内容,我也会在此添加,他们可能想在此处讨论模拟场景的地方查看此帖子。

Two views Multiple UIPickerViews Single outlet

关于ios - 查看方向更改,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6689325/

10-12 00:15
查看更多