开发者

Load XIB into a UIView

I have a UIView that is not covering the entire screen of an iPhone... about 200 pixels by 300 pixels.

I'm trying to load a xib into this view, but it seems to have an issue. The code works, but the UIView takes over everything at fullscreen... not at the determined width of the UIView.

Here is the code I have:

incViewPopU开发者_JAVA百科P = [[[NSBundle mainBundle] loadNibNamed:@"IncidentsViewController" owner:self options:nil] objectAtIndex:0];

I also tried adding it as a subview like below.. but that also does not work.

UIView *myView = [[[NSBundle mainBundle] loadNibNamed:@"IncidentsViewController" owner:self options:nil] objectAtIndex:0];
[incViewPopUP addSubView:myView];

Thanks for the help!


Adam, try this:

MyViewController *myViewController=[MyViewController alloc] initWithNib:@”IncidentsViewController”];

[myView addSubView:myViewController.view];

[myViewController release];

Just make sure after that the XIB has the right size for your UIView.


Did you try setting the frame size of myview programmatically ? Set myView.frame = CGRectMake (0,0,320,420) ? Or you can give your favorite value for that frame :)


You may need to remove all dummy components such as statusbar and other bars in IB from the view. From that point you can edit the size of the view within IB.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜