You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I made a NibLoadable view and added subviews.
However, those views are nil inside required init?(coder:) so I can't setup my views. (e.g. I want to set corner radius to a subview)
Where can I put additional init logic for NibLoadable?
The text was updated successfully, but these errors were encountered:
Are they still nil in awakeFromNib?
When unarchiving a nib, iOS/macOS first creates all instances of views etc found in the nib, calling init(coder:) on each (sub)view classes to create each instance… and only once all instances are created, link them together by connecting the outlets between them, and call awakeFromNib once all is set up. That's how NIBs work in general.
This is not related/restricted to Reusable btw, this behavior is true whenever you use XIBs, with or without Reusable: by the time init(coder:) is called, outlets are not yet connected so they are always nil. That's why you set up views in awakeFromNib, (or alternatively in the case of ViewControllers, more commonly in viewDidLoad), not in init.
Hi. I made a NibLoadable view and added subviews.
However, those views are nil inside required init?(coder:) so I can't setup my views. (e.g. I want to set corner radius to a subview)
Where can I put additional init logic for NibLoadable?
The text was updated successfully, but these errors were encountered: