I have some code that sets up buttons in my view before the the program is presented. Once the buttons are setup, there are no other changes to the UI for the rest of program execution. Should this code go in viewDidLoad?
This is the type of code I’m referring to:
UIButton *buyerButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buyerButton.frame = CGRectMake(leftSide, topSide+(c-1)*(buttonHeight+interButtonHeight), buttonWidth, buttonHeight);
[buyerButton setTitle:thisName forState:UIControlStateNormal];
[self.view addSubview:buyerButton];
Thanks for reading.
If by “setup” you mean create (alloc/init), then you should rather do it in
awakeFromNib:(if your view controller is loaded from a nib) or inloadView(if you create all of your GUI yourself).If you actually mean setup (and the buttons are already added from the nib) then yes, you can do additional setup in
viewDidLoad.