开发者社区> 问答> 正文

从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 1679 0
1 条回答
写回答
取消 提交回答
  • 在实例化PickerView时有没有设置它的代理.如果没有则不会调用它的这些协议方法

    picker.delegate=self;
    picker.datasource=self;
    2019-07-17 19:12:32
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载