不正确的UIView边界/模拟器中的绘制 [英] Incorrect UIView bounds/drawing in the Simulator
问题描述
我创建了一个单视图测试应用程序,并在主故事板上的UIViewController
中添加了UIButton
和UIView
.我已经调整了两个按钮的大小,使其具有相同的大小.
I've created a single-view test app and added a UIButton
and UIView
to the UIViewController
in the main storyboard. I have resized both the button an view to have the same size.
在我的VC的-viewDidAppear:animated方法中,我转储了按钮和视图的边框和边界:
In my VC's -viewDidAppear:animated method I dump the frame and bounds of the button and view:
- (void)viewDidAppear:(BOOL)animated
{
NSLog(@"button bounds: %@", NSStringFromCGRect(self.theButton.bounds));
NSLog(@"button frame: %@", NSStringFromCGRect(self.theButton.frame));
NSLog(@"view bounds: %@", NSStringFromCGRect(self.theView.bounds));
NSLog(@"view frame: %@", NSStringFromCGRect(self.theView.frame));
}
这是在模拟器中运行时的输出:
And here is the output when running in the simulator:
button bounds: {{0, 0}, {100, 100}}
button frame: {{110, 72}, {100, 100}}
view bounds: {{0, 0}, {100, 12}}
view frame: {{110, 179}, {100, 12}}
在设备上运行时:
button bounds: {{0, 0}, {100, 100}}
button frame: {{110, 72}, {100, 100}}
view bounds: {{0, 0}, {100, 100}}
view frame: {{110, 179}, {100, 100}}
我不明白为什么在模拟器中运行时视图报告高度为12.该视图在模拟器中绘制错误,但是在设备上运行时按预期绘制.请注意,UIViewController
的最高UIVIew
处于未选中状态的自动调整子视图"(尽管这两种方法都没有区别).
I do not understand why the view reports a height of 12 when running in the simulator. The view is drawn incorrectly in the simulator but draws as expected when run on a device. Note that the UIViewController
's topmost UIVIew
has "Autoresize Subviews" unchecked (although it doesn't make a difference either way).
(Xcode 4.5.2.iOS 6.0)
(Xcode 4.5.2. iOS 6.0)
谢谢, CS
推荐答案
在显示布局中单击应用Retina 4形状因数"按钮.您已经为Retina 4设置了此设置,因此在模拟器中运行时,屏幕的大小调整为3.5.您可以通过运行iPhone5模拟器(Retina 4英寸)来验证这一点.将形状系数切换为3.5英寸后,您会注意到高度更改为12.
Click the "Apply Retina 4 Form Factor" button in the display layout. You have this set for Retina 4 so the screen is resizing for 3.5 when running in the simulator. You can verify this by running the iPhone5 simulator (Retina 4 inch). You will notice the height changes to 12 after toggling the form factor to 3.5".
这篇关于不正确的UIView边界/模拟器中的绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!