简体   繁体   English

UIImageView问题-iPhone SDK

[英]UIImageView Question - iPhone SDK

I want to write an "if" statement of an uiimageview to see which image is in the image currently. 我想写一个uiimageview的“ if”语句来查看当前图像中的图像。 So if the uiimageview has this certain image, lets say "hello.png", then do this action. 因此,如果uiimageview具有此特定图像,则说“ hello.png”,然后执行此操作。 If it has "bye.png" then do this action. 如果它具有“ bye.png”,请执行此操作。

Thanks, 谢谢,

Kevin 凯文

I would do that by a BOOL field in your Model instead of checking the UIImageView. 我会通过您模型中的BOOL字段来执行此操作,而不是检查UIImageView。

You can update the boolean flag at the same time you update your imageview. 您可以在更新imageview的同时更新boolean标志。

MVC - Model View Controller. MVC-模型视图控制器。

Do not relly on view-related items for business logic. 不要依赖与视图相关的项目来进行业务逻辑。 You might change to a "MovieViewController" (I know it doesn't exist!) in the future and having the separation of concerns is the best. 您将来可能会更改为“ MovieViewController”(我知道它不存在!),最好将关注点分开。

UIImageView objects don't keep a name as part of the object. UIImageView对象不保留名称作为对象的一部分。 You need to keep track of what file is in what image view either by subclassing and adding a name attribute or some other means. 您需要通过子类化并添加name属性或其他方式来跟踪哪个图像视图中的文件。

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

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