如何在接口Bulider中为UIImage连接一个引用插座?

时间:2021-11-19 23:52:52

I want to access a UIImage programmatically... i.e. myImage.hidden = TRUE; etc. I can do this fine for UILabel but when I repeat the process for UIImage it doesn't work. Specifically when I drag the blue line in Interface Builder over the icon I don't get a popup menu like I do when using UILabel.

我想以编程方式访问UIImage ...即myImage.hidden = TRUE;我可以为UILabel做得很好但是当我重复UIImage的过程时它不起作用。特别是当我将界面生成器中的蓝线拖到图标上时,我没有得到像我在使用UILabel时那样的弹出菜单。

Perhaps using UIImageView instead of UIImage?

也许使用UIImageView而不是UIImage?

Thanks!

1 个解决方案

#1


4  

An UIImage is not a view that can be added via Interface Builder. In order to display a UIImage you either need to override the drawRect method of whatever view you want to display it in, or use a UIImageView.

UIImage不是可以通过Interface Builder添加的视图。为了显示UIImage,您需要覆盖要显示它的任何视图的drawRect方法,或者使用UIImageView。

Using a UIImageView will allow you to set it as an IBOutlet and reference it in your controller.

使用UIImageView将允许您将其设置为IBOutlet并在控制器中引用它。

#1


4  

An UIImage is not a view that can be added via Interface Builder. In order to display a UIImage you either need to override the drawRect method of whatever view you want to display it in, or use a UIImageView.

UIImage不是可以通过Interface Builder添加的视图。为了显示UIImage,您需要覆盖要显示它的任何视图的drawRect方法,或者使用UIImageView。

Using a UIImageView will allow you to set it as an IBOutlet and reference it in your controller.

使用UIImageView将允许您将其设置为IBOutlet并在控制器中引用它。