【发布时间】:2011-08-19 18:49:40
【问题描述】:
我不断收到这个错误,我已经设置了一个我试图显示的自定义单元格我已经在 IB 中连接了数据源和委托,但是我不断收到这个错误,下面是我的代码......就像我一样疯狂已经在另一个项目中完成了这项工作,而且效果很好。除了变量名之外,我没有更改任何内容。
2011-05-06 10:40:17.004 instaCode1.3[1500:207] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“UITableView 数据源必须从 tableView 返回一个单元格:cellForRowAtIndexPath:'
一切都被@synthesized 等等...
#pragma mark -
#pragma mark Table view data source
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
//This method adds headings to my sections
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSString *title = nil;
// Return a title or nil as appropriate for the section.
switch (section) {
case REG_SECTION:
title = @"Enter Registration";
break;
default:
break;
}
return title;;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
return cellRegistration;
}
return 0;
}
【问题讨论】:
-
cellRegistration 为零吗?
-
我现在已经为零了..但它仍然无法正常工作..我只是不知道我做错了什么。
-
您不希望 cellRegistration 为 nil。这是您要返回的单元格。
-
如何将其初始化为我在 Interfacebuilder 中创建的自定义单元格?
-
这完全是另一个问题。 stackoverflow.com/questions/540345/…
标签: iphone ios uitableview datasource