- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifire";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSString *makingString_fromArray = [appDel.Rhymes_Array objectAtIndex:indexPath.row];
NSArray *datatwoParts_Array = [makingString_fromArray componentsSeparatedByString:@"@"];
cell.textLabel.text = [datatwoParts_Array objectAtIndex:0];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
cell.backgroundColor = [UIColor clearColor];
cell.textLabel.textAlignment = NSTextAlignmentLeft;
// Assign our own background image for the cell
UIImage *background = [self cellBackgroundForRowAtIndexPath:indexPath];
UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
cellBackgroundView.image = background;
cell.backgroundView = cellBackgroundView;
return cell;
}
在我的表观视图中,只有第一个单元格数据显示,其他单元格。我还nslog the数组,每个索引上都存在数据,但在单元格中不显示。只有第一个单元数据显示。
确保您将计数返回为
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [datatwoParts_Array count];
}
还更改以下代码
的行cell.textLabel.text = [datatwoParts_Array objectAtIndex:0];
as。
cell.textLabel.text = [datatwoParts_Array objectAtIndex:indexPath.row];
编辑:
您的代码有点混乱,您要在这里实现什么?
NSString *makingString_fromArray = [appDel.Rhymes_Array objectAtIndex:indexPath.row];
NSArray *datatwoParts_Array = [makingString_fromArray componentsSeparatedByString:@"@"];
也请分享您的tableView:numberOfRowsInSection:
方法
检查您的
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if([datatwoParts_Array count]!=0)
return [datatwoParts_Array count];
return 0;
}
谢谢大家。问题是我在StringPath中获得了 r n,这就是为什么除了第一个单元格以外的文本。我使用nscharacterset从字符串中删除未使用的字符。
我在项目中发现的相同问题,我创建的这个表方法尝试了这个
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor clearColor];
cell.layer.backgroundColor = (__bridge CGColorRef)([UIColor clearColor]);//optional
cell.backgroundView = nil;
}
这应该与6.1 beta一起使用。
cell?.textLabel?.text = [datatwoParts_Array objectAtIndex:0]
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [datatwoParts_Array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.textLabel.text = [datatwoParts_Array objectAtIndex:indexPath.row];
NSLog(@" check the array value ======== %@",[datatwoParts_Array objectAtIndex:indexPath.row]);
}