在属于 UIViewController 的 UIImageView 中加载 UIImage

发布于 2024-12-06 18:55:08 字数 761 浏览 0 评论 0原文

所以我在笔尖中嵌套了这样的东西:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城旧梦 2024-12-13 18:55:08

针对您的问题尝试以下解决方案:

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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文