开发者

UIView Layout and applicationFrame

I am experiencing some weird behavior with my iPad app. I usually add a view to my viewController like this:

CGRect bounds = [[UIScreen mainScreen] applicationFrame];
// Add Basic View
UIView *myView = [[UIView alloc] initWithFrame:bounds];
myView.backgroundColor = [UIColor blackColor];
self.view =开发者_Go百科 myView;
[myView release];

On the iPhone this always works like a charm. On my iPad app however, I add a toolbar to this self.view as a subview with the rectangle (0, 0, self.view.frame.width, 100). Sometimes this works out well and the toolbar displays right below the status bar, yet in certain conditions (eg. when the iPad is lying flat on a table and the interface orientation is portrait) my toolbar slides partly below the status bar. Yet as soon as I rotate the device everything is fine again and the toolbar is aligned properly with the status bar.

I have tried some workarounds with adding values a few points to the origin.y property of the toolbar, yet when I do this the toolbar gets an offset to the status bar after rotating the device. I am really confused by this, did anybody else ever experience this problem? If so, how did you fix it?

Thanks a lot!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜