iOS:获取图像标签
我有这样的代码:
- (IBAction) checkIt:(id)sender{
NSString *button = [[(UIImageView *)sender label]text];
我想获取 UIImageView 的标签。我做错了什么?这适用于按钮...不确定我是否理解如何正确访问属性。
I have this code:
- (IBAction) checkIt:(id)sender{
NSString *button = [[(UIImageView *)sender label]text];
I want to get the label of the UIImageView. What am I doing wrong? This works with buttons...Not sure I understand how to access attributes correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
子类
UIImageView
。添加字符串成员和属性以访问它。不要创建 UIImageView 的对象,而是创建类的对象。.h
和 .m中
在要使用此类的文件的
Subclass
UIImageView
. Add a string member and property for accessing it. Instead of creating an object ofUIImageView
, create the object of your class.In .h
in .m
in the file where you want to use this class
UIImageView 没有标签。
https://developer.apple.com/库/ios/#documentation/uikit/reference/UIImageView_Class/Reference/Reference.html
UIImageViews do not have labels.
https://developer.apple.com/library/ios/#documentation/uikit/reference/UIImageView_Class/Reference/Reference.html