Search code examples
uiviewcontrollerios7viewdidload

Initialize ViewController in iOS 7


I used to initialize my UIViewController in - (void) viewDidLoad.

Since the update to iOS 7 the viewDidLoad method is either not called or after executing setItemAndParents.

Example:

I have a UITableViewController if you click on a cell the desired view is loaded:

- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath {
    // some more code
    [cpvc setItemAndParents:items[selectedIndex] orderIndex:indexOrder];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    cpvc = segue.destinationViewController;
}

Where am I supposed to initialize the ViewController.

Remember with iOS 6 everything worked find.


Solution

  • Yup it happens to me also... You can initialized view controller in - (void)awakeFromNib{} method. This method help me in the same scenario as you have.