UINavigationcontroller initWithRootViewController from appDelegate, empty view?
I ran into a problem.
I want to initialize an UINavigationcontroller with an UIViewController. As my Viewcontroller gets loaded from a .xib I am using
UINavigationController *myNavigationController = [[UINavigationController alloc] initWithRootViewController:appDelegate.myViewController];
[self presentModalViewController:myNavigationController animated:YES];
Unfortunately my view is empty.
Am I doing something wrong or is there an other way achieving my aim?
If I am allocating an instance of my Viewcontroller like so
UIViewController *aController = [[UIViewController alloc] initWithNibName:@"myViewController" bundle:[NSBundle mainBundle]];
And having a button inside the nib, my app crashes when tapping on it.
Thanks a lot.
myViewController *aController = [[myViewController alloc] initWithNibName:@"myViewController" bundle:[NSBundle mainBundle]];
or
UIViewController *aController = [[myViewController alloc] initWithNibName:@"myViewController" bundle:[NSBundle mainBundle]];
then push it
since
if u type like this
UIViewController *aController = [[UIViewController alloc] initWithNibName:@"myViewController" bundle:[NSBundle mainBundle]];
u allocating UIViewController and doesn't know about ur button in default UIViewcontroller
which means does n't have UIButton property.
so it crashes
链接地址: http://www.djcxy.com/p/87734.html上一篇: 通过UIViewController实现编程式的UIView
下一篇: 来自appDelegate的UINavigationcontroller initWithRootViewController,空视图?