UIView initWithFrame not working?

I set my view controller to a specific view through Interfacebuilder. but initWithFrame does not call, but drawRect is called? When did I set the breakpoint?

+6
iphone
source share
2 answers

That's right, because it does not guarantee that initWithFrame: will be called when unpacking xib. Try using awakeFromNib or viewWillLoad or viewDidLoad . Which one you choose mainly depends on what stage of the display process you need to insert your code into.

Also, look at this question .

+17
source share

According to the documentation - http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html - initWithFrame: not called when your view objects are then loaded from a file. The objects in the nib file are restored and then initialized using the initWithCoder: , which changes the presentation attributes according to the attributes stored in the nib file.

+3
source share

All Articles