开发者

UI Elements placed in IB appears shifted up in Simulator

开发者 https://www.devze.com 2023-01-09 09:48 出处:网络
I dont know if I am missing something here but when I drop elements (UIImage or UILabel) in IB and run the app 开发者_JS百科in simulator, the UI elements are shifting up a little (Snapping to status b

I dont know if I am missing something here but when I drop elements (UIImage or UILabel) in IB and run the app 开发者_JS百科in simulator, the UI elements are shifting up a little (Snapping to status bar if I place them at first blue HIG line).

Looks like some setting I am overlooking. Does this sound familiar? please help!

Added Screenshot to explain whats going on ...

  1. In Interface Builder

alt text http://dl.dropbox.com/u/3093402/Images/IB.png

  1. In Simulator

alt text http://dl.dropbox.com/u/3093402/Images/Simulator.png


Try this: select the view in Interface Builder and then in the Inspector, under “Simulated User Interface Elements,” change the status bar to “Gray.”

UI Elements placed in IB appears shifted up in Simulator


Ok ... heres whats happening in detail - http://discussions.apple.com/message.jspa?messageID=10861335

And heres what I did to resolve this - In the view controller code

- (void)viewDidLoad {
     CGRect newFrame = self.view.frame;
     newFrame.origin.y += 20;
     self.view.frame = newFrame;
    [super viewDidLoad];
}

Just move the frame of the newly added view (first view to the window) 20 pixels down and everything should fit nicely. This some how fixes view position for following views also. Dont know how?

Then you will see the UI elements exactly in the same position in Simulator and Device as you see in IB.

Hope this helps :)

Dev.

0

精彩评论

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