具有变化值的 UIpicker 数组
我正在制作一个应用程序,它使用选择器让用户选择年龄和其他一些输入。例如:我有一个按钮年龄,当用户单击它时,选择器会显示年龄。我设法为所有输入添加单独的选择器,但是我在为每个选择器设置不同的数组时遇到问题。
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (pickerview == picker) {
return [pickerViewArray objectAtIndex:row];
}
else if (pickerview == stagepicker)
return [stagepickerarray objectAtInde:row];
}
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
if (thePickerView == picker){ return [pickerViewArray count]; }
else if (thePickerView == stagepicker){ [stagepickerarray count]; }
}
上面的方法对我不起作用!我这样做对吗?
I'm making an app that uses the picker to let the user pick age and few other inputs. for eg: i have a button age, when the user clicks it, the picker shows the age. i managed to add individual picker for all the inputs, how ever i'm having problems setting different arrays for each picker.
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (pickerview == picker) {
return [pickerViewArray objectAtIndex:row];
}
else if (pickerview == stagepicker)
return [stagepickerarray objectAtInde:row];
}
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
if (thePickerView == picker){ return [pickerViewArray count]; }
else if (thePickerView == stagepicker){ [stagepickerarray count]; }
}
the above method isn't working for me !. Am I doing this right ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来不是应该将
pickerview
写成thePickerView
吗?是不是听起来
objectAtInde
应该是objectAtIndex
?听起来是不是好像某处缺少
return
?Doesn't it sound like
pickerview
should be writtenthePickerView
instead?Doesn't it sound like
objectAtInde
should beobjectAtIndex
?Doesn't it sound like a
return
is missing somewhere?为什么不将一个 UIPickerView 与多个组件一起使用?大致如下:
Why not use one UIPickerView with multiple components? Something along the lines of: