UI Elements placed in IB appears shifted up in Simulator

两盒软妹~` 提交于 2019-12-13 02:37:45

问题


I dont know if I am missing something here but when I drop elements (UIImage or UILabel) in IB and run the app 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


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/3335719/ui-elements-placed-in-ib-appears-shifted-up-in-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!