I would like to design a UIView, which is larger than a ViewController in Storyboard (iOS 5).
The UIView should be used as the subview of a UIScrollView and hence be larger than any of my existing ViewControllers. How can I create such a UIView in Storyboard and associate it with my UIScrollView?
I would like to do this without xib files if possible.
Thank you!
I see no other option than using xibs, but it's not that annoying:
//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;
In order to make IB connections you can set the filesOwner
class in the xib to be your viewController, and connect like usual.
You can place a UIView
into your scrollview and directly design it inside the viewController
of your scrollView
I've found the way to edit the view added to the scene (being at the same hierarchy level as ViewController).
Unfortunately it is from hackish
types of actions.
My Xcode
version is Version 4.5.2 (4G2008a)
. I've tested this in real project and new empty project.
The basic idea is that Xcode
do have an ability to edit such external views, unfortunately this mode doesn't activate straightforwardly.
In the method that I've found you need to have 2 levels of hierarchy inside your external view:
Scene |- VC |- View |- ExternalView |- SubView1 |- SubView2
Document Outline
panelSubView2
in the tree of your sceneThe editing area will appear and its coordinates will be saved to project's user data, so you can move it to more suitable place if you want to, and next time you'll open the storyboard in IB on the machine it will be there. Although I think on other machines you'll have to do it again (I haven't tested that).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With