有没有办法知道“setNeedsDisplay”的发送者是谁?
我有一些 UIpickerView 将 setNeedsDisplay
发送到其父视图。 有什么办法可以获取发件人的身份吗?
谢谢沙尼
I have a few UIpickerView's that sends setNeedsDisplay
to their parent view.
Is there any way to get the identity of the sender ?
Thanks
Shani
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法获取该方法的发送者。这里有一些重要的事情需要注意:首先,您根本不应该重写
setNeedsDisplay
,您应该重写drawRect:
,这将如果需要重绘视图,则调用该方法。其次,我建议您使用 UIPickerView 的 delegate 属性,将其设置为您的父视图,然后在 pickerView:didSelectRow:inComponent: 中执行您需要执行的任何处理委托方法。There is no way for you to get the sender of that method. There are a couple important things to note here: first, you shouldn't be overriding
setNeedsDisplay
at all, you should overridedrawRect:
which will be called if the view needs to be redrawn. Second, I would suggest you useUIPickerView
's delegate property, set it your parent view, and then do any processing you need to do in thepickerView:didSelectRow:inComponent:
delegate method.