使用 uitextfield 字符串实例化 UIPicker
我试图将我的 UItextfield 值传递给我在警报视图中加载的 UIPicker 我只是不确定可以使用哪些功能将值返回到选择器中?
猜测我应该在我的中做一些事情,
- (NSInteger)pickerView:(UIPickerView*)pv numberOfRowsInComponent:(NSInteger)component
{
if (pv == pickerViewA) {
return 10;
}
else
return 16;
}
但查看开发人员注意到,除了返回行数之外,他们没有太多关于 UIPickerViewDataSource 的信息......
任何帮助将不胜感激。
I am trying to pass my UItextfield value over to a UIPicker that I have loading in a alertview I'm just not sure what functions are available to me to get the values back into the picker?
At a guess I should be doing something in my
- (NSInteger)pickerView:(UIPickerView*)pv numberOfRowsInComponent:(NSInteger)component
{
if (pv == pickerViewA) {
return 10;
}
else
return 16;
}
but looking at the developers notes their is not much info about the UIPickerViewDataSource other than returning number of rows...
any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
还有其他数据源和代表 - 有关
更多信息,请参阅文档 -
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIPickerViewDelegate_Protocol/Reference/UIPickerViewDelegate.html
和
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPickerView_Class/Reference/UIPickerView.html
There are other data source and delegates as-
for more info look at documentation -
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIPickerViewDelegate_Protocol/Reference/UIPickerViewDelegate.html
and
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPickerView_Class/Reference/UIPickerView.html
您可以使用以下两个委托之一向 UIPickerView 添加数据内容
– pickerView:titleForRow:forComponent:
– pickerView:viewForRow:forComponent:reusingView:
对于第一个委托,您可以返回任何 NSString 对象,并且不能自定义字体大小等任何内容或颜色。
但是,如果您使用第二个,您可以将数据内容作为视图添加到 UIPickerView,这可以使用 UILabel 来实现,在这里您可以根据需要自定义视图。
希望这可以帮助您
快乐编码!
You can use either one of the following two delegates to add data content to UIPickerView
– pickerView:titleForRow:forComponent:
– pickerView:viewForRow:forComponent:reusingView:
For the first one u can return any NSString object and you cannot customize anything like font size or color for that.
But if you use the second one you can add the data content as a view to UIPickerView which can be achieved using a UILabel and here you can customize the view as you require.
Hope this might help you
Happy coding !