开发者

Why does an UIView in iOS/ appear too high up?

I'm relatively new to iOS programming. I have made a few basic apps before, and I'm getting back into it once again.

A problem I had a while back, and now is coming to haunt me is this.

When I create a new UIViewController subclass, myViewController (with xib) and add this code to get the add the view to the window, the contents always appear too high up, by the same width as the default/recommended left/right margin.

The code to add the view to the window is this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.


    MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
    [self setMyViewController:aViewController];
    [aViewController release];

    UIView *controllersView = [myViewController view];
   开发者_StackOverflow社区 [window addSubview:controllersView];

    [window makeKeyAndVisible];

    return YES;
}

For example, if I change the background colour of the view, I get a white strip at the bottom of the page when running in the simulator.

Any ideas?

Thanks


I don't think the problem is in that code. Although I guess you've done this already, it is probably a good idea to double check the .xib file. It may have an offset set in its position properties. Also, it may be caused by the status bar not being set correctly. If you want to hide it, you can add an entry (UIStatusBarHidden -> true) in the info.plist file to set it to be hidden. Either way check the dimensions of the .xib are the expected ones. And bear in mind the size of the status bar; the dimensions of the .xib file are different depending on whether the status bar is shown or not.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜