Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios -[UITableView\u configureCellForDisplay:forIndexPath:]中的断言失败_Ios_Xcode_Uitableview - Fatal编程技术网

Ios -[UITableView\u configureCellForDisplay:forIndexPath:]中的断言失败

Ios -[UITableView\u configureCellForDisplay:forIndexPath:]中的断言失败,ios,xcode,uitableview,Ios,Xcode,Uitableview,有人能告诉我为什么我会犯这个错误吗 这是我的.m文件: #import "ListaParticipantesViewController.h" #import "Participantes.h" #import "ModParticipantesViewController.h" @implementation ListaParticipantesViewController @synthesize dao; @synthesize participantes; - (void)view

有人能告诉我为什么我会犯这个错误吗

这是我的.m文件:

#import "ListaParticipantesViewController.h"
#import "Participantes.h"
#import "ModParticipantesViewController.h"

@implementation ListaParticipantesViewController

@synthesize dao;
@synthesize participantes;

- (void)viewDidLoad
{
    dao = [[ParticipantesDAO alloc] init];
    participantes = [[NSMutableArray alloc] init];
    participantes = [dao getDatos];
    [super viewDidLoad];

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [participantes count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"celda";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell.textLabel.text = [[participantes objectAtIndex:[indexPath row]] valueForKey:@"nombre"];

    return cell;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    ModParticipantesViewController *destino = [self.storyboard instantiateViewControllerWithIdentifier:@"visualizacion"];
    Participantes *tmp = [participantes objectAtIndex:[indexPath row]];
    destino.participante = tmp;

    [self.navigationController pushViewController:destino animated:YES];
}

@end
显示的错误为:

2013-04-13 17:40:20.235 Registro[5314:c07] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:5471
2013-04-13 17:40:20.237 Registro[5314:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(0x209d012 0x11aae7e 0x209ce78 0xc40665 0x1a4c1b 0x13940c 0x1a4a7b 0x1a9919 0x1a99cf 0x1921bb 0x1a2b4b 0x13f2dd 0x11be6b0 0x2699fc0 0x268e33c 0x2699eaf 0x1de2bd 0x126b56 0x12566f 0x125589 0x1247e4 0x12461e 0x1253d9 0x1282d2 0x1d299c 0x11f574 0x11f76f 0x11f905 0x128917 0xec96c 0xed94b 0xfecb5 0xffbeb 0xf1698 0x1ff8df9 0x1ff8ad0 0x2012bf5 0x2012962 0x2043bb6 0x2042f44 0x2042e1b 0xed17a 0xeeffc 0x306d 0x1ef5)
libc++abi.dylib: terminate called throwing an exception
(lldb)

提前谢谢

序列图像板或XIB没有使用您指定的单元标识符定义的单元。

我遇到了同样的错误。原来也是这个问题,它找不到我的单元格标识符,但原因不同-我正在对UITableViewCell进行子类化,但没有为reuseIdentifier向我的UITableView注册.XIB文件

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

  return cell; // at the end of your method 
}
我通过在viewDidLoad中重新点击解决了这个问题

- (void)viewDidLoad {
  [super viewDidLoad];

  //LOAD XIB
  UINib *nib = [UINib nibWithNibName:@"NAME_OF_NIB_FILE"
                              bundle:nil];

  //REGISTER XIB, CONTAINING THE CELL (IDENTIFIER NAME USUALLY SAME AS NIB NAME)
  [[self tableView] registerNib:nib
         forCellReuseIdentifier:@"IDENTIFIER_NAME"]; 
}
然后创建单元格

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

  //GET THE RECYCLED CELL
  TableCellSubclass *cell = [tableView dequeueReusableCellWithIdentifier:@"IDENTIFIER_NAME"];

  //CONFIGURE THE CELL

  return cell;
}

希望这对别人有帮助

就我而言,我犯了一个简单的错误

我的行数是由array.count定义的

当我刷新这个数组时,我正在删除所有对象,启动连接,将对象添加到数组中,然后重新加载tableview


连接完成后,我将对象移除,解决了我的问题

是否已使用UITableViewDelegate、UITableViewDataSource类对ListaParticipantsViewController进行子类化?他们需要能够使用委托和数据源方法

迅速:

class ListaParticipantesViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
}

您需要在标题中设置tableview的委托和数据源

目标c

<UITableViewDataSource, UITableViewDelegate>

}

哇,谢谢!所以第一个错误消失了。。。我只是不断收到2013-04-13 19:35:07.303注册表[6194:c07]***由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[valueForUndefinedKey:]:该类不符合密钥nombreParticipante的键值编码。”当您将nil返回到
-(UITableViewCell*)时,可能会重复此断言tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
奇怪的是,几个月后我又回到这一页来评论而不是回答,但这次你的回答帮了我的忙!我的单元格在登录时为空,因此我检查了我的初始化,并使用了[tableView dequeueReusableCellWithIdentifier:@“cell\u REUSE\u IDENTIFIER”],这在我将代码从情节提要中移出时应该是显而易见的!无论如何,谢谢你。“孩子们,检查你们的手机初始化”
class HomeViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {