In my iOS application I try to present new ViewController "above" current one. Following this Apple guideline, in some event I use the following code:
MyViewController* vc = [[MyViewController alloc] initWithNibName: nil bundle: nil];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
UINavigationController* nc = [[UINavigationController alloc] initWithRootViewController: vc];
[mainController presentViewController:nc animated:YES completion:nil];
This code is called (and it happens after main controller is successfully loaded, not within viewDidLoad) and new view appears using chosen transition style.
MyViewController class is created, and its methods like viewDidLoad and supportedInterfaceOrientations are successfully called.
Now here goes the problem.
In interface builder I create controller, setting its class to MyViewController. I create a number of views inside this controller, UIButton, for example. MyViewController has the property
IBOutlet UIButton* button
On storyboard, referencing outlet of placed UIButton is set to "button" property of the controller. As a double-check, in "Outlets" section of the view controller on storyboard "button" is bound to the placed UIButton object.
But when viewDidLoad
is called, value of button property is nil. Naturally, button doesn't display. The same goes for two UITableView
objects (they dataSource and delegate are both set to the same view controller and MyViewController conforms
<UITableViewDelegate, UITableViewDataSource>
in case it's important).
In addition, black screen that appears ignores all touches (and swipe gesture recognizer is placed on the controller on storyboard). But it reacts on orientation changes.
I suppose the problem is that created instance of MyViewController fails to "see" the storyboard and I miss something very basic, but I see no hints in Apple documentation.