Menu
  • HOME
  • TAGS

Calling awakeFromNib from xib file in the main ViewController

objective-c,uitableview,xib,custom-cell,awakefromnib

awakeFromNib is an initializer called when you load from nib..ie you add a view and change its class to your custom class in storyboard/nib and this porcess will call awakeFromNib method..not programatically When done programatically use init method for the purpose or a custom initializer -(id)init { //class super init...

How to Call awakeFromNib in mainViewController.m

objective-c,uitableview,xib,custom-cell,awakefromnib

awakeFromNib is called when all file owners outlets and properties are set. Things are not wired up (in terms of frames/layout) in viewDidLoad. awakeFromNib is called after viewDidLoad, that is why you see the difference....

Trying to set a property inside a UIView before awakeFromNib is called

ios,uitableview,swift,uiview,awakefromnib

If you want to use a var as soon as you have it, you can use it's didSet observer like so: class ListUsersView: UIView { @IBOutlet var tableView: UITableView! { didSet{ tableView.registerNib(UINib(nibName: nameForCellNib!, bundle:NSBundle.mainBundle()), forCellReuseIdentifier: nameForCellNib!) } } . . . } ...

Call DataSource method in awakeFromNib

ios,objective-c,datasource,awakefromnib

If you put a breakpoint in -awakeFromNib method, you'll see that this method executes as it should. The thing is, that this method called before datasource assignment, and at this moment your self.datasource is nil. I suggest you to override the setter of the datasource property and initialize your data...

How do I get an objects height from awakeFromNib to my mainViewController.m?

ios,objective-c,xib,awakefromnib

I have had the worst luck loading nibs and issues searching for an easy way to do so. This is what worked for me in the past. Add this to customCell.m - (id)initWithNib { // where MyCustomView is the name of your nib UINib *nib = [UINib nibWithNibName:@"customCell" bundle:[NSBundle mainBundle]];...