解析一个feed到NSMutableArray,填充UIPickerView
如下:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [items count];
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [items objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
{
id item = [items objectAtIndex:row];
NSString *occasion = [item objectForKey:@"name"];
location.text = occasion;
}
但是运行之后,UIPickerView没有任何值,请高手提供解决方法。谢谢。
在实例化PickerView时有没有设置它的代理.如果没有则不会调用它的这些协议方法
picker.delegate=self;
picker.datasource=self;