【问题标题】:After rotate 4 time my scrollview is work旋转 4 次后,我的滚动视图正常工作
【发布时间】:2017-06-27 10:34:35
【问题描述】:

我是 iOS 的新手,我学习了客观的 c 语言。 在这里,我尝试使用滚动视图和屏幕旋转,下面的代码是发布的,当运行应用程序时滚动视图无法显示或工作,但经过四次旋转滚动视图工作。 所以请帮助我。 谢谢。

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        //Landscape
        /*self.view.frame = CGRectMake(0, 0, 1024, 728);
        self.view.hidden = NO;*/
        //self.scrollView.frame = CGRectMake(0, 0, 1024, 728);
        [_scrollView setContentSize:CGSizeMake(736, 1000)];

    } else {
        //self.view.frame = CGRectMake(0, 0, 414, 800);
        [_scrollView setContentSize:CGSizeMake(414 , 1200)];
        //self.View.hidden=NO;
        //self.view.hidden=YES;
    }
}

【问题讨论】:

    标签: ios objective-c uiscrollview


    【解决方案1】:

    请您在 ViewDidLoad 方法中设置 Scrollview contentSize。

    【讨论】:

    • 如果滚动视图不滚动,可能会出现错误,例如滚动视图内容大小不大于 滚动视图大小,或者如果您在滚动视图上使用约束,则设置不正确。如果您在 xib 中创建滚动视图,请首先将 UIView 创建为 UIScrollView 的子视图以使其成为 contentView。
    • 嘿,scrollView 正在滚动,但您在 scrollView 工作后向右、向左、向上、向下旋转 4 次。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多