4

我有一个 UIScrollView,我放置在视图中(界面构建器文档 .xib/.m/.h),但是 UIScrollView 的下半部分被剪裁并且由于我有一个 UITabBarController 而没有显示其自身的下半部分。

我在 appdelegate 文件中实现了 UITabBarController,因此在 XIB 中没有看到 UITabBarController,但是如果我在 XIB 中放置另一个 UITabBarController 来模拟我已经创建的那个,我会在测试应用程序时得到两个。

这是视图外的 UIScrollView 的快照。这显示了 UIScrollView 的下半部分......


(来源:img-up.net

这是正在运行的应用程序的快照。注意图片的下半部分和笔记是如何被切断的(只是勉强!)


(来源:img-up.net

基本上-->我怎样才能显示滚动视图底部的其余部分?(图片/注释部分)没有被 UITabBarController 切断?

4

3 回答 3

2

Keep in mind that the view from the nib is being automatically resized as it is placed inside the tab bar interface, so you want the scroll view to go along for the ride, and not stick out off the bottom of the resized view as it is doing now. Thus, you should either place the scroll view higher up in the view, or else use autolayout constraints (iOS 6) or autoresizing springs and struts (iOS 5) so that the bottom of the scroll view sticks to the bottom of the view, so that as the bottom moves up (the view gets shorter), the scroll view moves up with it.

(In the nib editor, you can ask the editor to simulate the presence of a tab bar [Simulated Metrics > Bottom Bar > Tab Bar], just to give yourself an idea of what the final size will be; but the right approach is to use appropriate constraints/autoresizing so that the view can be resized and its contents will still be visible. For one thing, that allows you adapt to both the iPhone 4 screen and the iPhone 5 screen.)

于 2013-04-28T17:49:26.443 回答
2

查看ScrollView 文档。如果您查看有关配置大小的部分,它会解释您应该设置内容插入,以便控制器不会切断内容。

似乎您需要使用以下内容设置底部 contentInset:

scrollView.contentSize=CGSizeMake(320,758); // Or whatever your content size is
scrollView.contentInset=UIEdgeInsetsMake(64.0,0.0,44.0,0.0);
// 64.0 being the top inset, and 44.0 being the bottom inset
// Set the bottom inset to the height of your tab bar or more

这将确保您的标签栏不会从您的视图中被遮挡。

于 2013-05-20T23:43:48.257 回答
1

最快的方法是将 xib 中的视图大小重新调整为 UITabBarController 的内容大小,尽管已经回答了更有效的方法。在右侧的属性中,您可以将主视图设置为“自由形式”,并将其设置为 320 x 392 或您的部分有多大。

如果您想查看 4 英寸和 3.5 英寸的应用程序,最少的工作就是使用自动调整大小遮罩完成上述答案

于 2013-04-28T17:55:34.917 回答