简体   繁体   English

如何检测UIButton背景图片变化?

[英]How to detect UIButton background image change?

I work on iOS 8 with objective C on Xcode. 我在Xcode上使用目标C在iOS 8上工作。 I need to create two viewControllers. 我需要创建两个viewControllers。 First: button with background image that is changed to some random image, and go to second controller. 首先:将背景图片更改为随机图片的按钮,然后转到第二个控制器。 Second: Present button image name 第二:当前按钮图片名称

Both view Controllers are created but, i need to know about : 创建两个视图控制器,但是,我需要了解:

1.How to detect that the image on the button is changed on the First view ,if i now on Second viewController? 1.如果我现在在第二视图控制器上,如何检测按钮上的图像在第一视图上是否已更改?

2.How to pass the file name to the second viewController ? 2.如何将文件名传递给第二个viewController?

you can get back the image with : 您可以通过以下方式获取图像:

[self.button currentImage] [self.button currentImage]

(also works with currentBackgroundImage/Title/TileColor... rtfm ;)) (也适用于currentBackgroundImage / Title / TileColor ... rtfm;)

To pass data to your second view controller many options exists, you can use "prepareForSegue" and set you next view button/NString whatever :) 要将数据传递给第二个视图控制器,存在许多选项,您可以使用“ prepareForSegue”并将下一个视图按钮/ NString设置为:)

Good Luck ;) 祝好运 ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM