Assuming I load a view controller from a nib, and decide to do something with one of its subview behind the scene. At a later moment in time, I would show the view of this view controller.
viewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[viewController.someSubview doSomething];
//later on
[mainView addSubview:viewController.view];
The problem is that, the someSubview object doesn't seem to be loaded until the view appears, so the method doSomething is not called. So far my workaround is to call:
[mainView addSubview:viewController.view];
[viewController.view removeFromSuperview];
to initialize the subviews of viewcontroller first. Is there any more elegant way (like a loadSubviews method or something) for this task?