Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bounds of custom UIView not correct during awakeFromNib - when are they set?

I have a custom UIView, which I have placed using Xcode (4). I need to set some default state, based on the actual bounds of the view. During awakeFromNib, bounds seems to be returning the size of the view in the storyboard layout in Xcode.

The view is in the detail side of a UISplitViewController, which in Xcode is the size of a full portrait iPad screen, but if the app loads in landscape mode then, via springs-and-struts, its size is changed, but this appears to happen after awakeFromNib.

Should I be setting this state in some other method?

like image 928
Jono Avatar asked May 16 '12 14:05

Jono


1 Answers

It depends what sort of state you are setting - if it is dependent on the bounds then you'll need to reset it every time the device is rotated, presumably? In that case overriding setFrame: might be a better bet - be sure to call the superclass implementation before you do anything else, though.

like image 83
jrturton Avatar answered Oct 20 '22 00:10

jrturton