繁体   English   中英

iOS 6-XCode 4.5.1-iPad模拟器-以编程方式获得错误的分辨率

[英]iOS 6 - XCode 4.5.1 - iPad simulator - programatically getting wrong resolution

为什么以编程方式签出XCode 4.5.1中的Ipad模拟器显示错误的大小?

MainViewController.m

- (void)viewDidLoad{
    [super viewDidLoad];

    [self.view setBackgroundColor:[UIColor redColor]];

    NSLog(@"self.view width : %f",self.view.frame.size.width);
    NSLog(@"self.view height : %f", self.view.frame.size.height);

    mTextView  =   [[UITextView alloc] initWithFrame:CGRectMake(10.0, 10.0, self.view.frame.size.width - 20, self.view.frame.size.height/2)];
    [self.view addSubview:mTextView];
}

我得到的输出为

self.view width : 320.000000
self.view height : 548.000000

我的项目规格

  1. 通用项目
  2. 针对iOS 6.0
  3. 我绝对可以肯定,在创建MainViewController时,我选中了“ 针对ipad ”复选框
  4. 不知道它是否重要,但是未选中“使用xib作为用户界面”。

这是添加了textview的屏幕截图

在此处输入图片说明

尝试等到:

- (void)viewWillAppear

在设置UITextView的框架之前。 根据这篇文章 ,在那之前您将没有有效的几何图形。

尝试使用以下代码来确定您的计算机了解该设备:

NSRange*  pointRange = [[[UIDevice currentDevice] model] rangeOfString:@"iPad" options:0];

if (pointRange.location == NSNotFound) {

    NSLog(@"iPhone");
}
else

  {
    NSLog(@"iPad");

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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