如何在Interface Builder中创建多个超出xib的元素 [英] how to create many elements in Interface Builder that overflow beyond the xib

查看:108
本文介绍了如何在Interface Builder中创建多个超出xib的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIView,其中有很多元素,如Text Field,Date Picker和Picker View,可以将数据添加到我的应用程序中。这不会在Interface Builder的屏幕中显示。在我看来,用户将向下滚动以插入它们。有没有办法实现这个目标?

I have a UIView where has so many elements like Text Field, Date Picker, and Picker View to add data to my app. This won't make it in a screen in Interface Builder. In my mind, user will scroll down to insert them. Is there a way to achieve this?

谢谢

推荐答案

如何在Interface Builder中设置高于480像素的视图。

这将使用两个xib文件完成:

This will be done using two xib files:

MainView.xib 是MainViewController的视图,它高460像素。

TallView.xib 是600像素高的视图(有关如何在IB中执行此操作,请参见下文)。

MainView.xib is the view for MainViewController, it is 460 pixels tall.
TallView.xib is a 600 pixel tall view (see below for how to do this in IB).

MainViewController仅包含UIScrollView。您的所有内容都应位于 TallView.xib

MainViewController only contains a UIScrollView. All your content should be in TallView.xib

MainViewController 中,覆盖 viewDidLoad 并使用以下代码:

In MainViewController, override viewDidLoad and use the following code:

viewDidLoad:

- (void)viewDidLoad {

    //load your TallView.xib into a UIView object
    NSArray *nibParts = [[NSBundle mainBundle] loadNibNamed:@"TallView" 
                                                      owner:nil 
                                                    options:nil];
    //first object is the view
    UIView *tallView = [nibParts objectAtIndex:0];

    //add tallView to scrollView 
    [scrollView addSubview:tallView];

    //set content size to same dimensions as TallView.xib
    scrollView.contentSize = CGSizeMake(320, 600);
}

如何在Interface Builder中创建高于480像素的视图

首先将模拟界面元素设置为none,覆盖xib的高度超过480,然后更改高度。

Override the height of a xib beyond 480 by first setting the simulated interface elements to "none", and then change the height.

看两个屏幕截图:
alt text http://static.benford.name/IBViewAttributes.png

alt text http://static.benford.name/IBViewSize.png

这篇关于如何在Interface Builder中创建多个超出xib的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆