如何在不使用Interface Builder的情况下以编程方式在视图中设置UIPickerView
?当我从第一个UIPickerView
中选择一个值,第二个UIPickerView
更改这些值时,也无法理解如何执行两个UIPickerView
?
第一个UIPickerView
国家/地区和第二个UIPickerView
城市。
答案 0 :(得分:0)
请参阅以下链接
http://gabriel-tips.blogspot.in/2011/04/uipickerview-add-it-programmatically_04.html http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPickerView_Class/index.html http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-implement-pickerview-programmatically-in-iphone/
对于两个选择器视图,您可以使用标记值或将其放在属性中。
答案 1 :(得分:0)
Yes possible you can create array on city within country like
int select=0;
(
india
(
city,
.....,
)
Australia
(
City,
......,
)
)
and use
picker
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if(picker==1)
{
return [arr_counry count];
}
else if(picker==2)
{
return [[arr_counry objectAtIndex:select] count];
}
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if(picker==1)
{
select=[arr_currency objectAtIndex:row];
[picker reloadAllComponents];
}
else if(picker==2)
{
}
}