我正在开发一个应用程序,为了节省我所做的 View ,我希望能够动态地将 View 传递给图像。例如,我做了一个 View :
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
然后我想在呈现之前设置 View 的 imageview 显示的图像:
UIImage *image = [UIImage imageNamed: @"IMG_5010_2.jpg"];
[controller.imageView setImage:image];
[controller.label setText:@"HI"];//I am trying to do this too and it isn't working...
但它就是不起作用!有人对此有什么想法吗?请帮忙!!
谢谢
注意:我确实在我尝试呈现的 View 上设置了 UIImageView 和 UILabel 属性...
最佳答案
您应该在相关 UIViewController 的 viewDidLoad 方法中设置图像因为 View 在初始化阶段不会存在,并且会在调用 viewDidAppear 时显示。
关于iphone - 在呈现 View 之前如何设置 UIImageView 的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4901864/