[英]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. 我正在尝试在屏幕顶部下方显示一些
UIView
(例如, UIButton
或UITextView
)。 I do not use IB nor autolayouts: I am trying to do it manually. 我既不使用IB也不使用自动布局:我正在尝试手动进行。 I have my status bar disabled , hence my
applicationFrame
== bounds
of default screen. 我禁用了状态栏,因此我的
applicationFrame
==默认屏幕的bounds
。
My UIView's frame.origin.y
is 0
. 我的UIView的
frame.origin.y
是0
。 On IPhone4 and IPad (emulation) it works correctly: I see my element in the left top corner. 在iPhone4和IPad(模拟)上,它可以正常工作:我在左上角看到我的元素。 But when I set emulator to IPhone5 the element is is not displayed (actually, it is displayed above the screen).
但是,当我将模拟器设置为IPhone5时,则不会显示该元素(实际上,它显示在屏幕上方)。 When I set its
y
to about 50 it is displayed correctly. 当我将其
y
设置为大约50时,它会正确显示。
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. iPhone 4正在运行哪个iOS版本?如果iPhone 6或更低版本将正确显示。 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.
在iOS 7及更高版本中,如果要使其位于状态栏下方,则必须将topLayoutGuide添加到视图的frame.origin.y中。 Im sure your simulator is running iOS 8, thats why it doesnt display right there.
我确定您的模拟器正在运行iOS 8,这就是为什么它不在那里显示的原因。
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"). 我刚刚发现状态栏(带有电池指示器的状态栏)即使打开了也不会显示在iPhone5仿真器中(“状态栏最初是隐藏的== NO”)。 I scrolled my emulator and found bar and my
UIView
! 我滚动了模拟器,找到了bar和
UIView
! For some reason IPhone5 (but not Iphone4 nor IPad!) emulator starts with screen scrolled. 由于某种原因,iPhone5(而不是Iphone4或IPad!)仿真器会在屏幕滚动时启动。 Probably I created view to big to fit the screen (which is strange because
applicationFrame
is used). 可能我创建的视图大到适合屏幕(这很奇怪,因为使用了
applicationFrame
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.