objective-c – 使用按钮更改UIImage视图的图像

objective-c – 使用按钮更改UIImage视图的图像,第1张

概述嘿,我的应用程序中有一个 ImageView,我希望用户能够通过单击按钮更改该图像视图中的图像.这是我得到的代码 在.h @interface BGViewController : UIViewController { IBOutlet UIImageView *image;}@property (nonatomic, retain) IBOutlet UIImageView * 嘿,我的应用程序中有一个 ImageVIEw,我希望用户能够通过单击按钮更改该图像视图中的图像.这是我得到的代码

在.h

@interface BGVIEwController : UIVIEwController {    IBOutlet UIImageVIEw *image;}@property (nonatomic,retain) IBOutlet UIImageVIEw *image;-(IBAction)img1:(ID)sender;-(IBAction)img2:(ID)sender;

在.m

@synthesize image;-(IBAction)img1:(ID)sender; {    UIImage *image = [UIImage imagenamed: @"Main.png"];}-(IBAction)img2:(ID)sender; {    UIImage *image = [UIImage imagenamed: @"themes.png"];}

顺便说一句,每个图像都有一个按钮!

该应用程序构建,但当我点击任何一个按钮时,没有发生.

解决方法 更换
UIImage *image = [UIImage imagenamed: @"Main.png"];

UIImage *image = [UIImage imagenamed: @"themes.png"];

image.image = [UIImage imagenamed:@"Main.png"];

image.image = [UIImage imagenamed:@"themes.png"];

现在它应该工作正常:)

总结

以上是内存溢出为你收集整理的objective-c – 使用按钮更改UIImage视图的图像全部内容,希望文章能够帮你解决objective-c – 使用按钮更改UIImage视图的图像所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1241900.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存