xcode 如何在 iOS 故事板中将图像添加到 ImageView

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24972613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:16:56  来源:igfitidea点击:

How to add image to ImageView in iOS storyboard

iosxcodeuitableviewuiimageviewstoryboard

提问by learner

Is there a way to add a default image to an imageView through the storyboard? I UIImageView in question is a view inside a TableViewCell. I can't seem to find the option in the storyboard, and I am convinced this kind of option should definitely exist.

有没有办法通过情节提要向 imageView 添加默认图像?我有问题的 UIImageView 是 TableViewCell 内的一个视图。我似乎无法在故事板中找到该选项,而且我确信这种选项绝对应该存在。

回答by learner

I finally see it under Attributes Inspector. I can also drag and drop from Media Library (basically the same place where I select my views): in case someone else is lost.

我终于在属性检查器下看到了它。我也可以从媒体库(基本上是我选择视图的地方)拖放:以防其他人丢失。

回答by Nex Mishra

In the case of a UITableViewCell, give a tag to the image view:

在 UITableViewCell 的情况下,给图像视图一个标签:

UIImageView *myimage = (UIImageView *)[cell viewWithTag:1];
myimage.image = [UIImage imageNamed:@"imagename"];