Ios cell.textlab.text工作不正常
在我的tableview中,只有第一个单元格数据显示,其他单元格为空。我还记录了数组中的数据,每个索引中都有数据,但没有显示在单元格中。Ios cell.textlab.text工作不正常,ios,iphone,objective-c,ios7,Ios,Iphone,Objective C,Ios7,在我的tableview中,只有第一个单元格数据显示,其他单元格为空。我还记录了数组中的数据,每个索引中都有数据,但没有显示在单元格中。 仅显示第一个单元格数据。感谢帮助请确保将计数返回为 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CellId
仅显示第一个单元格数据。感谢帮助请确保将计数返回为
- (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;
}
还要更改以下代码行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [datatwoParts_Array count];
}
作为
编辑:
你的代码有点混乱,你想在这里实现什么
cell.textLabel.text = [datatwoParts_Array objectAtIndex:indexPath.row];
另外,请共享您的
表格视图:numberofrowsin节:
方法确保将计数返回为
- (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;
}
还要更改以下代码行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [datatwoParts_Array count];
}
作为
编辑:
你的代码有点混乱,你想在这里实现什么
cell.textLabel.text = [datatwoParts_Array objectAtIndex:indexPath.row];
另外,请分享您的表格视图:numberOfRowsInSection:
方法检查您的
NSString *makingString_fromArray = [appDel.Rhymes_Array objectAtIndex:indexPath.row];
NSArray *datatwoParts_Array = [makingString_fromArray componentsSeparatedByString:@"@"];
检查你的
NSString *makingString_fromArray = [appDel.Rhymes_Array objectAtIndex:indexPath.row];
NSArray *datatwoParts_Array = [makingString_fromArray componentsSeparatedByString:@"@"];
谢谢大家。
问题是我在Stringpath中得到了\r\n,这就是为什么第一个单元格以外的文本不显示的原因。
我使用NSCharacterset从字符串中删除了未使用的字符。谢谢大家。
问题是我在Stringpath中得到了\r\n,这就是为什么第一个单元格以外的文本不显示的原因。
我使用NSCharacterset从字符串中删除了未使用的字符。我在项目中发现的问题和我创建的这个表方法尝试解决这个问题
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if([datatwoParts_Array count]!=0)
return [datatwoParts_Array count];
return 0;
}
我在我的项目和我创建的这个表格方法中发现了同样的问题,我试图解决这个问题
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if([datatwoParts_Array count]!=0)
return [datatwoParts_Array count];
return 0;
}
这应该适用于6.1测试版
- (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]);
}
这应该适用于6.1测试版
- (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]);
}
请显示您的
表格视图:numberofrowsin部分:
method@KIDdAe接得好。删除了我的答案,因为问题不是cellforrowatinexpath:
只被呼叫一次?或者对于数组中的每个项目?请显示您的表视图:numberofrowsin节:
method@KIDdAe接得好。删除了我的答案,因为问题不是cellforrowatinexpath:
只被呼叫一次?或者对于数组中的每个项目?如果是这样的问题,他会看到所有单元格中的相同文本。。。并且datatwoParts\u数组不是一个属性。@KIDdAe理解。首先我提到了tableView:numberOfRowsInSection:method。如果是这样的问题,他会看到所有单元格的相同文本。。。并且datatwoParts\u数组不是一个属性。@KIDdAe理解。首先我提到了tableView:numberOfRowsInSection:method。