2011-05-27 65 views
0

我面對共同的錯誤都UIPickerview和UITableView的,即UIPicker觀點和看法UITable

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4d32080> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key CurrencyPicker.' 

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4b2c070> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView.' 

請幫我,爲什麼這些。

我認爲這是由於tableview和picker視圖的數據源和委託連接到fileowner。但我已經做好了一切。

Plz幫助我。

謝謝。

+0

張貼一些代碼..... – 2011-05-27 12:56:06

+0

還要確保所有IB插座連接正確 – Joetjah 2011-05-27 12:59:21

+0

@ Joetjah :雅,所有IB插座連接正確。 – 2011-05-27 13:15:44

回答

0

我覺得this後可以幫助您

0

@Aman:這裏是代碼:

@祖阿曼:在setting.h

@interface Setting : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>{ 
    UIButton *button; 

    NSMutableArray *CurrencyArray; 
    IBOutlet UIPickerView *CurrencyPicker; 
} 

在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]; 
}