属性设置得太早时,UIImageView不显示图像 [英] UIImageView not displaying image when property is set too early
本文介绍了属性设置得太早时,UIImageView不显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个要显示在 UIView
中的图像.在Interface Builder中, UIView
是根,而 UIImageView
是其子代.
I have an image I want to display inside a UIView
. In Interface Builder, the UIView
is the root and a UIImageView
is its child.
视图连接到视图控制器的视图出口,图像视图连接到图像视图出口:
The view is connected to view controller's view outlet, and the image view is connected to the image view outlet:
@property (nonatomic, retain) IBOutlet UIImageView *imageView;
如果我尝试在 UIImageView
的图像属性设置为可见之前,就不会显示该图像.
If I try to set the image property of UIImageView
before it's visible, the image doesn't show up.
TestView *testView = [[TestView alloc] initWithNibName:@"TestView" bundle:nil];
testview.imageView.image = [logos objectAtIndex:indexPath.row];
[self.navigationController pushViewController:testView animated:YES];
但是,如果我将图像传递给控制器并在 viewDidLoad
中设置image属性,则图像变为可见.
If, however, I pass the image to the controller and set the image property in viewDidLoad
, the image becomes visible.
TestView *testView = [[TestView alloc] initWithNibName:@"TestView" bundle:nil];
testview.image = [logos objectAtIndex:indexPath.row];
[self.navigationController pushViewController:testView animated:YES];
- (void)viewDidLoad
{
[super viewDidLoad];
imageView.image = image;
}
是什么导致图片在第一种情况下无法显示?
What is causing the image to not show up in the first scenario?
推荐答案
查看全文