简体   繁体   中英

Setting UIView on the left top corner is broken in ios Emulator/IPhone5?

I am trying to display some UIView (say, UIButton or UITextView ) right below the top of the screen. I do not use IB nor autolayouts: I am trying to do it manually. I have my status bar disabled , hence my applicationFrame == bounds of default screen.

My UIView's frame.origin.y is 0 . On IPhone4 and IPad (emulation) it works correctly: I see my element in the left top corner. But when I set emulator to IPhone5 the element is is not displayed (actually, it is displayed above the screen). When I set its y to about 50 it is displayed correctly.

Is it an emulation bug or something worng with my code?

What version of iOS is the iPhone 4 running?, if its 6 or lower then it will display it correctly. From iOS 7 and above you have to add the topLayoutGuide to the frame.origin.y of a view if you want it to be below the status bar. Im sure your simulator is running iOS 8, thats why it doesnt display right there.

I just found that status bar (the one with battery indicator) is not displayed in IPhone5 emulator even if I turn it on ("status bar is initially hidden == NO"). I scrolled my emulator and found bar and my UIView ! For some reason IPhone5 (but not Iphone4 nor IPad!) emulator starts with screen scrolled. Probably I created view to big to fit the screen (which is strange because applicationFrame is used).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM