UIPicker 视图和 UITable 视图

发布于 2024-11-10 06:01:35 字数 637 浏览 3 评论 0原文

我在 UIPickerview 和 UITableview 中都面临常见错误,即

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.'

帮助我解释为什么会出现这些错误。

我认为这是由于数据源以及表视图和选择器视图与文件所有者的委托连接所致。但我每件事都做对了。

请帮帮我。

谢谢。

I am facing on common error in both UIPickerview and UITableview, 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

早乙女 2024-11-17 06:01:38

@Aman:这里是代码:

@Aman:在

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

    NSMutableArray *CurrencyArray;
    IBOutlet UIPickerView *CurrencyPicker;
}

setting.m中的setting.h中

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

@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];
}
伤感在游骋 2024-11-17 06:01:37

我认为这篇文章可能会有所帮助你

I think this post could help you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文