我将一个收藏夹数组--从一个细节视图--传递给(应该是什么)一个表视图,单独显示收藏夹。第一个视图中的第一个数组是可以的:
Array found. Contents: (
"\U5df4",
"\U5df4",
"\U82ad\U8305//\U5df4\U8305",
"\U5df4\U5bb6",
"\U7b06\U7bd3\U513f",
"\U5df4",
"\U5df4",
"\U5df4",
"\U5df4",
"\U5df4",
"\U5df4\U5bb6",
"\U5df4",
"\U5df4",
"\U5df4"
)
Number of items in my array is: 15并从第二个视图中的第二个数组中打印它。
Printing description of self->FavsTwo:
<__NSCFArray 0x1f9644a0>(
巴,
巴,
芭茅//巴茅,
巴家,
笆篓儿,
巴,
巴,
巴,
巴,
巴,
巴家,
巴,
巴,
巴,
巴家
)也很酷..。
我得到的第一个休息是在这里:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [FavsTwo count];
}然后所有这些错误:
*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:6235
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
***我的手机是这样的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSString *cellValue = [self.FavsTwo objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}试图将对象转换为字符串-不太确定它在哪里失败
干杯
发布于 2014-03-07 08:50:27
你在tableView:numberOfRowsInSection:中失去了自我
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.FavsTwo count];
}如果dequeueReusableCellWithIdentifier:不能破坏一个单元格,它可以返回nil。
您需要检查单元格是否为nil。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell) {
cell = [UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]
}
NSString *cellValue = [self.FavsTwo objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}如果您使用过registerClass:forCellReuseIdentifier:或registerNib:forCellReuseIdentifier:.The,则需要使用dequeueReusableCellWithIdentifier:forIndexPath:获取单元格。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSString *cellValue = [self.FavsTwo objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}发布于 2014-03-07 08:49:00
cellForRowAtIndexPath返回零,如果不能ReusableCell,则应创建带有CellIdentifier的单元格。
试试这个:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSString *cellValue = [self.FavsTwo objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}https://stackoverflow.com/questions/22245338
复制相似问题