0
以下代碼在運行OS7.1或OS8.1的iPhone 4s模擬器中按預期方式工作,並顯示我嘗試加載的圖像的非零幀大小。 iPhone 5或6模擬器中的相同代碼不加載圖像併爲其顯示零大小的框架。有什麼不同?iphone 5模擬器不會將圖像加載到UIImage中?
UIView *_webBorder;
UIImageView _messagesIcon;
_webBorder = [[UIView alloc] init];
_webBorder.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_webBorder.layer.borderColor = [UIColor blackColor].CGColor;
_webBorder.layer.borderWidth = 1.0;
_webBorder.backgroundColor = [UIColor colorWithRed:0.5 green:0.2 blue:0.9 alpha:0.5];
[self.view addSubview: _webBorder];
_messagesIcon = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"mIcon"]];
[_webBorder addSubview: _messagesIcon];
NSLog(@"message icon's frame is %@", NSStringFromCGRect(_messagesIcon.frame));
XCode version 6.1.1。