I am trying to create a custom UIView class with an associated Nib (.xib) file to help with layout and creation.
Right now, no subviews in my custom view appear, even though they exist in my nib file and are hooked up properly to my custom view class via IBOutlets.
I tried going through the following other answer: Load custom UIView with XIB from a View Controller's view using IB
and this one: How do I get a view in Interface Builder to load a custom view in another nib?
and this one: http://soulwithmobiletechnology.blogspot.com/2011/06/create-uiview-with-nib-file-in-xcode-4.html
but the method [[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil]
seems to call -[initWithCoder:]
, leading to an infinite loop.
Please let me know what other details to include to help solve this bug!
UPDATE 1: Do I need to lay out my subviews via -[layoutSubviews]
? Does my nib file actually not lay it out? If so, then what is the point of the nib file?
Open any of your view controllers and paste this code into your
viewDidAppear
method:That's all you have to do, to present a view. If you want to interact with this view — you have to declare
MyCustomView* problemView
in your class' interface, not in the method.