开发者

UIViewController with no Xib showing blank when using pushViewController

开发者 https://www.devze.com 2023-04-11 22:55 出处:网络
I have subclassed UIViewController like so: @interface MyClass : UIViewController I dont have a xib file for the controller, instead I would just like to use a blank UIView and I will layout elemen

I have subclassed UIViewController like so:

@interface MyClass : UIViewController

I dont have a xib file for the controller, instead I would just like to use a blank UIView and I will layout elements programmatically on that. The problem arrises when I try and push this view controller.

MyClass * thing = [[ImageGallery alloc] init];
[self.navigationController pushViewController:thing animated:YES];

A new title bar is animated in, but there is no view, its see throug开发者_开发百科h, so I end up seeing a static background I set on my main "window/view". How should I properly subclass a UIViewController without a xib?


What you have described is correct behaviour so far.

You will want to override the -(void)loadView method, and after the [super loadView]; call, you can set your background colour and begin to place the objects in programatically, that you desire.

0

精彩评论

暂无评论...
验证码 换一张
取 消