4

我很难处理设计适合 3.5 英寸 iPhone 和 5 英寸 iPhone(模拟器)的布局。我检查了自动布局,所有布局都很完美。但是我现在需要使用 UIScrollView,因此需要取消选中自动布局才能使用。

此外,当使用 iPhone 4 英寸显示屏查看布局时,它会在 UIScrollView 的顶部增加大约 60 像素。

有没有更好的方法来做到这一点(设置滚动视图而不取消选择自动布局)?所以我可以支持 iPhone 4。

//to set up the scrollview
[self.scrollView setScrollEnabled:YES];
[self.scrollView setContentSize:CGSizeMake(320, 800)];

但是在我取消选中自动布局之前它不会滚动。有一个更好的方法吗?

4

4 回答 4

1

尝试自动调整大小,

 self.scrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin);
于 2013-10-10T10:59:09.720 回答
0

UIScrollView使用 Autolayout 时略有不同。你需要做一些修改。你的答案就在这里

于 2013-10-10T10:51:21.597 回答
0

你可以对你的UIScrollView frame. 按照下面的 CGRect 将框架分配给滚动视图。

CGRect rect=[[UIScreen mainScreen] bounds];

希望,这对你有用。

于 2013-10-10T10:58:21.590 回答
0

试试这个(它解决了我的问题):

scrollView addConstraint:[NSLayoutConstraint constraintWithItem:lastSubView
                                         attribute:NSLayoutAttributeRight
                                         relatedBy:NSLayoutRelationEqual
                                            toItem:scrollView
                                         attribute:NSLayoutAttributeRight
                                        multiplier:1.0
                                          constant:0]];

参考:UIScrollView 不使用自动布局约束

于 2013-11-18T19:27:22.850 回答