Loading a UIImage in a UIImageView that is part of a UIViewController
So I have things nested like this in a nib:
UIViewController
|
|-UIView (con开发者_StackOverflowtainer for some about text UILabel)
| |
| UILabel
|
UIScrollView (makes image scalable)
|
UIImageView
I'm trying to load the image of the UIImageView programmatically in another view controller, then pushing the new UIViewController onto a UINavigationController. Everything works fine, but when I assign the image, nothing appears on the new view.
So in a connectionDidFinishLoading: I do this:
UIImage* image = [UIImage imageWithData:imageData];
MyImageController* imageController = [[MyImageController alloc] init];
imageController.title = expandImage.title;
imageController.imageView.image = image;
[self.navigationController pushViewController:imageController animated:YES];
Nothing shows up besides what I designed in the nib. Any help?
Try these solution for your problem:
1.First of all, be sure that you get an image and you have an image data in the imageData
variable.
2.most likely this solution is what you are looking for. declare a variable in the MyImageController
of type UIImage
, and set the propriety and synthesize for it, then in your connectionDidFinishLoading
code, set the returned image to the variable that you declare, and in the MyImageController
assign the variable to the imageController.imageView
.
i hope that help you, and tell me what you got from these solution
good luck.
精彩评论