2013-03-20 69 views
-1

当我尝试通过XIB加载单元格时,应用程序崩溃,并给我以下异常。无法从XIB加载Cell

*终止应用程序由于未捕获的异常NSUnknownKeyException,原因:[<MyAdsViewController 0x7a38e30> setValue:forUndefinedKey:]:这个类不是键值编码兼容的关键转盘。

任何人都可以帮助解决这个问题。

+0

你想添加自定义单元格? – 2013-03-20 06:33:22

+0

在这里发布您的代码,以便我们可以在需要时纠正您的错误 – 2013-03-20 06:39:12

+1

嘿,伙计们,thx为您提供有利的回复。因为有一个iboutlet设置为错误的视图。现在,它的工作。 Thx – Nirmalsinh 2013-03-20 07:28:43

回答

2

试试这个::

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Configure the cell. 
    static NSString *CustomCellIdentifier = @"customCell"; 
    customCell *cell = (customCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier]; 

    if (cell == nil) 
    { 
     NSArray *nib; 
     nib = [[NSBundle mainBundle] loadNibNamed:@"customCell" owner:self options:nil]; 

     for (id oneObject in nib) 
      if ([oneObject isKindOfClass:[customCellr class]]) 
       cell = (customCell *)oneObject; 

     cell.title.text = @"Hello"; 
    } 
    return cell; 
} 

希望,它会帮助你。

谢谢。

+0

Yupp,如果有异常,那么应用程序不会与您的代码粉碎。 thx man – Nirmalsinh 2013-03-20 09:10:30

+0

快乐来帮助你..享受编码.. :) – 2013-03-20 09:11:21

0

你需要去这个类的XIB,并检查任何有链接警告的东西,像这样enter image description here

删除这些类型的链接,然后运行您的应用程序。

0

尽力为细胞创建对象,并按照下面的代码ü能够做到这一点

(UITableViewCell *)tableView:(UITableView *)tableview_ cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString 
*simpleTableIdentifier = @"SimpleTableCell"; 

ISOPriceCell *cell = (ISOPriceCell *)[tableview_ dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell 
== nil) { 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ISOPriceCell" owner:self options:nil]; 
    cell = [nib objectAtIndex:0]; 
    cell.priceTextFiled.keyboardType = UIKeyboardTypeNumberPad; 
    cell.priceTextFiled.delegate = self; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone;}}