让 UIButton showDetails 接受参数
我的 MKMapView 上有许多 UIButton 元素。当用户单击按钮时,我会收到 showDetails 通知。但是我如何知道用户点击了哪个按钮呢?我所知道的唯一技巧是传入整数标签值。当然必须有一种更优雅的方式。我尝试对 UIButton 进行子类化,但由于它是一个集群,因此我无法对它进行子类化并使用 UIButton 的所有现有功能。
谢谢 德肖恩
I have many UIButton elements on my MKMapView. When the user clicks on a button I get a showDetails notification. But how do I tell which button the user clicked on? The only hack I know of is to pass in the tag value which is an integer. Surely there must be a more elegant way. I tried subclassing UIButton but since it is a cluster, I cannot subclass it and use all of theUIButtons existing functionality.
Thanks
Deshawn
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标签是识别的好方法,您还可以使用当前标题来区分所有按钮是否具有不同的标题。这是一个代码片段
,但我更喜欢使用标签。
tag is a good way to identify you can also use current title to differentiate if all buttons have different titles. here is a code snippet
But I prefer use tags.