如何在Storyboard中的任何ViewController之外设计单独的UIView?

Ale*_*exR 10 objective-c uiscrollview uiview ios ios5

我想设计一个UIView,它比Storyboard(iOS 5)中的ViewController大.

UIView应该用作UIScrollView的子视图,因此比我现有的任何ViewControllers都要大.如何在Storyboard中创建这样的UIView并将其与我的UIScrollView相关联?

如果可能的话,我想在没有xib文件的情况下这样做.

谢谢!

Joh*_*und 20

除了使用xib之外我没有其他选择,但这并不令人讨厌:

//We have file called "View.xib" in our project. It contains one SINGLE view
NSArray *xibContents = [[NSBundle mainBundle] loadNibNamed:@"View" owner:self options:nil];
UIView *view = [xibContents lastObject]; //safer than objectAtIndex:0

[self.scrollview addSubview:view];
self.scrollview.contentSize = view.frame.size; 
Run Code Online (Sandbox Code Playgroud)

为了建立IB连接,你可以将filesOwnerxib中的类设置为viewController,并像往常一样连接.