您正在为NULL
Key设置值
编辑:在您开始使用选择器之前,您需要:
在 .h 文件中:
UIViewController<UIPickerViewDelegate,UIPickerViewDataSource>{
NSArray *array;
}
然后在 .m 文件中:
-(void)viewDidload{
[super viewDidload];
array = [[NSArray alloc]initWithObjects:@"Lake",@"Diana",@"Jone",@"Alice",@"Byber",@"Nuces",nil];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [array count];
}
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
/* do what you want if the picker selected */
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [array objectAtIndex:row];
}