[英]Can anyone tell me why tableview data are not displaying until scroll?
In my tableview i have set xml data to display but until scroll it does not display all value. 在我的表视图中,我已设置要显示的xml数据,但是直到滚动它并不会显示所有值。 I have reloaded the tableview when i am getting my xml data.
当我获取xml数据时,我已经重新加载了tableview。 I also used
[cell.contenView viewWithTag:tagnumber];
我还使用了
[cell.contenView viewWithTag:tagnumber];
But still now its not Working...please help me anybody.... 但是现在它仍然不起作用...请帮助我任何人...
Data are coming and using NSLog
i can get the value but not display until scroll. 数据即将来临,使用
NSLog
我可以获取该值,但是直到滚动才显示。 One think i have to mention that i can see the my cellview and imageview but not showing lable data. 有人认为我不得不提到我可以看到我的单元格视图和图像视图,但没有显示标签数据。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
//cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15.0];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"]];
cell.accessoryView = imageView;
tableView.separatorColor = [UIColor clearColor];
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
// THIS IS A VIEW ABOVE MY CELL NAME: cellView
cellView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,290, 120)] autorelease];
cellView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"order_description_bg.png"]];
cellView.tag =10;
// THIS IS A IMAGEVIEW ABOVE MY cellView NAME: imgView
imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 15, 39, 36)];
imgView.image = [UIImage imageNamed:@"order_image.png"];
imgView.layer.borderColor = [UIColor blackColor].CGColor;
imgView.layer.borderWidth = 0.0f;
imgView.tag = 5;
// THIS IS A LABEL ABOVE MY cellView NAME: statusLabel
CGRect statusRect = CGRectMake(65, 0, 190, 18);
statusLabel = [[[UILabel alloc] initWithFrame:statusRect] autorelease];
statusLabel.textAlignment = UITextAlignmentLeft;
statusLabel.textColor = [UIColor blackColor];
statusLabel.font = [UIFont systemFontOfSize:12];
statusLabel.backgroundColor = [UIColor greenColor];
statusLabel.tag = 1;
[cell.contentView addSubview:cellView];
[cellView addSubview:statusLabel];
[cellView addSubview:imgView];
}
// [cell.contentView superview];
cellView = (UIView *)[cell.contentView viewWithTag:10];
imgView = (UIImageView *)[cellView viewWithTag:5];
statusLabel = (UILabel *)[cellView viewWithTag:1];
if(searching == YES && x<=inumOfRowAfterSearch){
NSLog(@"[[searchData objectAtIndex:m] intValue] is : %d",[[searchData objectAtIndex:inumOfRowAfterSearch] intValue]);
y = [[searchData objectAtIndex:inumOfRowAfterSearch] intValue];
cellView = (UIView *)[cell.contentView viewWithTag:10];
imgView = (UIImageView *)[cellView viewWithTag:5];
statusLabel = (UILabel *)[cellView viewWithTag:1];
if(pendingOrder == NO && todaysOrder == NO && x<=inumOfRowAfterSearch){
statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:y] objectAtIndex:1]];
}
else if(pendingOrder == YES && todaysOrder == NO && x<=inumOfRowAfterSearch){
statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:y] objectAtIndex:1]];
}
}
else{
cellView = (UIView *)[cell.contentView viewWithTag:10];
imgView = (UIImageView *)[cellView viewWithTag:5];
statusLabel = (UILabel *)[cellView viewWithTag:1];
if(pendingOrder == NO && todaysOrder == NO){
statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:1]];
NSLog(@"status lable value: %@",statusLabel.text);
}
else if(pendingOrder == YES && todaysOrder == NO){
statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[pendingRecords objectAtIndex:indexPath.section] objectAtIndex:1]];
}
}
return cell;
}
Before scroll the table. 滚动表格之前。
After Scroll the tableview 滚动表视图后
Following codes are not necessary in each condition , since you have written the code outside of the condition. 由于您已在条件之外编写了代码,因此在每种情况下都不需要遵循以下代码。 It seems duplicate.
似乎重复。
cellView = (UIView *)[cell.contentView viewWithTag:10];
imgView = (UIImageView *)[cellView viewWithTag:5];
statusLabel = (UILabel *)[cellView viewWithTag:1];
And coming to your question, it seems initially it skips both if
and else if
conditions. 谈到您的问题,似乎最初它会同时跳过
if
和else if
条件。 Comment also the NSLog
s and write NSLog
in else
part of the conditions. 还注释
NSLog
并在条件的else
部分中写入NSLog
。
Edit: 编辑:
// [cell.contentView superview];
cellView = (UIView *)[cell.contentView viewWithTag:10];
imgView = (UIImageView *)[cellView viewWithTag:5];
statusLabel = (UILabel *)[cellView viewWithTag:1];
if(searching == YES && x<=inumOfRowAfterSearch){
NSLog(@"[[searchData objectAtIndex:m] intValue] is : %d",[[searchData objectAtIndex:inumOfRowAfterSearch] intValue]);
y = [[searchData objectAtIndex:inumOfRowAfterSearch] intValue];
if(pendingOrder == NO && todaysOrder == NO ){
statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:y] objectAtIndex:1]];
}
else if(pendingOrder == YES && todaysOrder == NO ){
statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:y] objectAtIndex:1]];
}
else
{
statusLabel.text = [NSString stringWithFormat:@"Status: None"];
}
}
else{
if(pendingOrder == NO && todaysOrder == NO){
statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:1]];
NSLog(@"status lable value: %@",statusLabel.text);
}
else if(pendingOrder == YES && todaysOrder == NO){
statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[pendingRecords objectAtIndex:indexPath.section] objectAtIndex:1]];
}
else
{
statusLabel.text = [NSString stringWithFormat:@"Status: None"];
}
}
return cell;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.