开发者社区 问答 正文

从feed获取充填UIPickerView

解析一个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没有任何值,

展开
收起
爵霸 2016-03-24 11:49:36 1738 分享 版权
1 条回答
写回答
取消 提交回答
  • 在实例化PickerView时有没有设置它的代理.如果没有则不会调用它的这些协议方法

    picker.delegate=self;
    picker.datasource=self;
    2019-07-17 19:12:32
    赞同 展开评论
问答分类:
问答地址: