【问题标题】:Rotating landscape mode旋转横向模式
【发布时间】:2010-08-31 10:38:47
【问题描述】:

我所做的是将 10 个图像显示为网格,3 个图像在 portroide 模式下显示,而我所做的是每当我将模拟器旋转到横向时,我必须显示 4 个图像。它也使用代码显示

if(self.interfaceorientation == UIIntefaceorientationPortrait) {
[self abc];
else {
[self abclandscape];
}

这里 abc 和 abclandscape 是两个可以正常工作的函数,但是,如果我旋转到横向模式或纵向模式,它从初始状态开始工作,它工作正常。而在中间,如果我从横向旋转到纵向,它就不行转到 [self abc] 函数。我该如何解决这个问题?

【问题讨论】:

    标签: iphone


    【解决方案1】:

    你可以做的是要么使用 UIViewController 委托,要么使用 NSNoticationCenter。
    IE。添加您的“viewDidLoad”:

            [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
                                                         name:UIDeviceOrientationDidChangeNotification object:nil];
    

    并添加功能:

    - (void)orientationChanged:(NSNotification *)notification
    {   
        UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
        if (UIDeviceOrientationIsLandscape(deviceOrientation))
        {
        // Do one thing
        }
        else 
        {
        // Do something else
        }
    }
    

    【讨论】:

      【解决方案2】:

      @mahesh 在 shouldAutoRototate 方法中

            use
      
           if(self.interfaceorientation == UIIntefaceorientationPortrait||self.interfaceorientation == UIIntefaceorientationPortraitUp..)
      

      { } 别的 { }

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多