UIScrollView 作为 UISplitViewController 中的根视图
我有一个基本的 UISplitViewController,其中根视图控制器的视图(即不是详细视图)是 UIScrollView。问题是当我去设置 UIScrollView 的内容大小时,我看到运行时的frame.size.width为768.0,即使Interface Builder显示宽度为320.0。
换句话说,我想执行以下操作,但宽度是 768.0 而不是 320.0。有什么想法。提前致谢!
self.dayScrollView.contentSize = CGSizeMake(dayScrollView.frame.size.width, dayScrollView.frame.size.height * 2);
I have a basic UISplitViewController where the view of the root view controller (i.e. not the detail view) is a UIScrollView. The problem is when I go to set the content size for the UIScrollView, I see that the frame.size.width is 768.0 at runtime, even though Interface Builder shows the width as being 320.0.
In other words, I'd like to do the following but the width is 768.0 instead of 320.0. Any thoughts. Thanks in advance!
self.dayScrollView.contentSize = CGSizeMake(dayScrollView.frame.size.width, dayScrollView.frame.size.height * 2);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UISplitViewController 将把视图控制器的大小调整为它自己的内容大小,在纵向模式下(不确定我头顶上的风景)肯定会是 768.0。只要将上面的代码放置在 viewWillAppear 中或稍后调用的方法中,它就应该可以正常工作。您可能需要详细说明,以防我遗漏了某些内容。
The UISplitViewController is going to resize the view controller to its own content size, which for sure in portrait mode (not sure about landscape off the top of my head) is going to be 768.0. As long as the code you put above is placed in viewWillAppear or a method called later than that, it should work just fine. You may need to elaborate more in case I missed something.