【问题标题】:scrollview lock in portrait orientation ios6ios6纵向滚动视图锁定
【发布时间】:2012-11-01 09:19:20
【问题描述】:

我必须将滚动视图锁定为纵向而不是横向。

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        scrollview.scrollEnabled=YES;
        NSLog(@"inside the landscape rotation");
    }
    else
    {
        scrollview.scrollEnabled=NO;
        NSLog(@"inside the portrait rotation");
    }
}

上述方法工作正常,但我必须旋转一次设备 - 有没有办法在不改变方向的情况下将滚动视图锁定在 potrait 中?

提前致谢。

【问题讨论】:

    标签: uiscrollview ios6 orientation uiinterfaceorientation device-orientation


    【解决方案1】:

    您可以将您的锁定代码放入viewDidLayoutSubviews,如下所示:

    - (void)viewDidLayoutSubviews
    {
        [super viewDidLayoutSubviews];
    
        if(UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))
        {
            scrollview.scrollEnabled = YES;
            NSLog(@"inside the landscape roatation");
        }
        else
        {
            scrollview.scrollEnabled = NO;
            NSLog(@"inside the portrait roatation");
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-05
      • 1970-01-01
      • 2011-04-11
      • 2014-04-02
      相关资源
      最近更新 更多