无法调用 titleForRow 方法 UIPickerView
在我的 viewcontroller 类中,我有一个属性 UIViewPicker
myPicker。在 didSelectRow 方法中(也由 UIPicker 委托实现。我尝试以下方法
NSString* temp = [self.myPicker titleForRow:1 inComponent:0].
,但它说找不到该方法,并说返回类型默认为“id”。
我做错了什么???`
in my viewcontroller class i have a property UIViewPicker
myPicker. in didSelectRow method (also implemented by the UIPicker delegate. I try the following
NSString* temp = [self.myPicker titleForRow:1 inComponent:0].
However it says that the method is not found and says that return type defaults to "id".
What am i doing wrong????`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
“它说找不到该方法”,因为这是 UIPickerViewDelegate 的委托方法。查看 Apple 文档。委托方法是实现的,而不是调用的!委托就像侦听器,它们的方法需要由实现委托的类来实现。这些方法是自动调用的,并且调用它们的顺序是预先定义的。您只需要知道调用它们的条件即可。
您始终可以创建自己的方法,只要它们与委托方法不同即可。
"it says that the method is not found" because this a delegate method for UIPickerViewDelegate. Check the Apple Documentation. Delegate methods are implemented, NOT called! Delegates are like listeners and their methods need to be implemented by the class that implements the delegates. The methods are called automatically and the order in which they are called is predefined. You only have to know the conditions under which they are called.
You can always create your own methods as long as they are different from the delegate methods.
这是一个委托方法,您可以使用它来设置行的特定标题。我不相信你可以通过这样的实例来调用它。您需要在当前控制器(应该实现 UIPickerViewDelegate)中单独实现此方法,然后从那里开始工作。
例如
}
This is a delegate method which you can use to set particular titles for rows. I don't believe you can call it via an instance like this. You'll need to implement this method separately in your current controller (which should implement the UIPickerViewDelegate) and then work from there.
e.g.
}
尝试以下声明
,我认为它会解决您的问题。
谢谢萨蒂亚
try the following statement
I think,it will solve your problem.
Thanks
Satya
尝试这样的操作。
您可以在提到的方法中
You can try like this
inside the mentioned method.