I am facing on common error in both UIPickerview and UI开发者_开发技巧Tableview, i.e.
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4d32080> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key CurrencyPicker.'
and
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4b2c070> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView.'
Please help me why these are.
I think it is due to datasource and delegate connection of tableview and picker view to fileowner. but I have done every thing right.
Plz help me out.
Thanks.
I think this post could help you
@Aman: Here is code:
@ Aman:in setting.h
@interface Setting : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>{
UIButton *button;
NSMutableArray *CurrencyArray;
IBOutlet UIPickerView *CurrencyPicker;
}
in setting.m
- (void)viewDidLoad {
[super viewDidLoad];
CurrencyArray = [[NSMutableArray alloc] init];
[CurrencyArray addObject:@" Rs "];
[CurrencyArray addObject:@" R$ "];
[CurrencyArray addObject:@" $ "];
[CurrencyArray addObject:@" ƒ "];
[CurrencyArray addObject:@" ман "];
button=(UIButton *)[self.view viewWithTag:1];
[CurrencyPicker selectRow:1 inComponent:0 animated:NO];
[button setTitle:[CurrencyArray objectAtIndex:[CurrencyPicker selectedRowInComponent:0]] forState:UIControlStateNormal];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
return 1;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
[button setTitle:[CurrencyArray objectAtIndex:row] forState:UIControlStateNormal];
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
return [CurrencyArray count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
return [CurrencyArray objectAtIndex:row];
}
精彩评论