在属于 UIViewController 的 UIImageView 中加载 UIImage
所以我在笔尖中嵌套了这样的东西:
UIViewController
|
|-UIView (container for some about text UILabel)
| |
| UILabel
|
UIScrollView (makes image scalable)
|
UIImageView
我试图以编程方式在另一个视图控制器中加载 UIImageView 的图像,然后将新的 UIViewController 推送到 UINavigationController 上。一切工作正常,但是当我分配图像时,新视图上没有显示任何内容。
因此,在 ConnectionDidFinishLoading: 中,我这样做:
UIImage* image = [UIImage imageWithData:imageData];
MyImageController* imageController = [[MyImageController alloc] init];
imageController.title = expandImage.title;
imageController.imageView.image = image;
[self.navigationController pushViewController:imageController animated:YES];
除了我在笔尖中设计的内容之外,什么也没有显示。有什么帮助吗?
So I have things nested like this in a nib:
UIViewController
|
|-UIView (container 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
针对您的问题尝试以下解决方案:
1.首先,确保您获得图像并且
imageData
变量中有图像数据。2.很可能这个解决方案就是您正在寻找的。在
MyImageController
中声明一个UIImage
类型的变量,并为其设置属性和合成,然后在connectionDidFinishLoading
代码中设置返回的图像到您声明的变量,并在MyImageController
中将该变量分配给imageController.imageView
。我希望对您有所帮助,并告诉我您从这些解决方案中得到了什么,
祝您好运。
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 typeUIImage
, and set the propriety and synthesize for it, then in yourconnectionDidFinishLoading
code, set the returned image to the variable that you declare, and in theMyImageController
assign the variable to theimageController.imageView
.i hope that help you, and tell me what you got from these solution
good luck.