如何使用 selectedRowInComponent 从 uialertview 内的 uipicker 返回字符串
我在 uialertview 中创建了一个 uipicker,当有人选择一个 UITextfield 时会弹出,我在
- (void)textFieldDidBeginEditing:(UITextField *)myTextField{
方法内部创建了这个,在这个方法中我还创建了一个“完成”和“取消”按钮,我已将其连接到他们自己的方法...我遇到的问题是在
-(void)doneButtonPressed:(id)sender{
这个方法内部我也想捕获 uipicker 的设置...但是它给了我一个警告...
-(void)doneButtonPressed:(id)sender{
//Do something here here with the value selected using [pickerView date] to get that value
[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
NSString *hexString = [NSString stringWithFormat:@"%x%x%x%x%x", [pickerViewPopup selectedRowInComponent:0], [pickerViewPopup selectedRowInComponent:1], [pickerViewPopup selectedRowInComponent:2],
[pickerViewPopup selectedRowInComponent:3]];
dateCode.text = hexString;
这会引发警告 UIActionSheet 可能不会响应 SelectedRowInComponent...任何想法如何绕过这个警告?
I have created a uipicker in a uialertview that pops up when someone selects a UITextfield I have created this inside the
- (void)textFieldDidBeginEditing:(UITextField *)myTextField{
method, inside this I have also created a Done and Cancel button that I have hooked up to their own methods... The one that I am having trouble with is the
-(void)doneButtonPressed:(id)sender{
Inside this method I want to catch what the uipicker has been set too.. however its giving me a warning...
-(void)doneButtonPressed:(id)sender{
//Do something here here with the value selected using [pickerView date] to get that value
[pickerViewPopup dismissWithClickedButtonIndex:1 animated:YES];
NSString *hexString = [NSString stringWithFormat:@"%x%x%x%x%x", [pickerViewPopup selectedRowInComponent:0], [pickerViewPopup selectedRowInComponent:1], [pickerViewPopup selectedRowInComponent:2],
[pickerViewPopup selectedRowInComponent:3]];
dateCode.text = hexString;
this throws a warning UIActionSheet may not respond to SelectedRowInComponent... any idea on how to get around this warning?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否有可能您错误地将 pickerViewPopup 初始化为 UIActionSheet 的对象?因为 UIActionSheet 没有名为 selectedRowInComponent 的方法。
再次检查 pickerViewPopup 初始化,可能会有所帮助。
Is it possible that you have wrongly initialize pickerViewPopup to be an object of UIActionSheet?, because the is no method called selectedRowInComponent for UIActionSheet.
Check the pickerViewPopup initialization again, it might help.