Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 上下滚动时复制的单元格子视图_Ios_Tableview - Fatal编程技术网

Ios 上下滚动时复制的单元格子视图

Ios 上下滚动时复制的单元格子视图,ios,tableview,Ios,Tableview,我有一个UITableView,我正在以编程方式使用它。在其cellforrowatinexpath中,我正在执行以下操作,但单元格上没有显示任何内容。同样在didselecrow中,我打算在点击的单元格中添加一个标签,但每次我上下滚动时,标签都会复制到另一个单元格中。代码如下: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLo

我有一个UITableView,我正在以编程方式使用它。在其
cellforrowatinexpath
中,我正在执行以下操作,但单元格上没有显示任何内容。同样在
didselecrow
中,我打算在点击的单元格中添加一个标签,但每次我上下滚动时,标签都会复制到另一个单元格中。代码如下:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Fire Cell for Row Podcast");

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)
{
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    //Title
    LabelTitle = [UILabel new];
    LabelTitle.tag = 1;
    LabelTitle.textColor = [UIColor colorWithRed:42/255.0f green:54/255.0f blue:97/255.0f alpha:1];
    NSString *strTitle = [NSString stringWithFormat:@"%@",[content.podcastTitle objectAtIndex:indexPath.row]];
    [DynamicUI DynamicLabel:LabelTitle textInput:strTitle fontContent:[UIFont fontWithName:@"DroidArabicNaskh-Bold" size:12] originX:15 originY:30 originW:295];
    [cell.contentView addSubview:LabelTitle];

    // Date
    LabelDate = [UILabel new];
    LabelTitle.tag = 2;
    LabelDate.textColor = [UIColor colorWithRed:164/255.0f green:153/255.0f blue:57/255.0f alpha:1];
    [cell.contentView addSubview:LabelDate];
    NSString *strDate = [NSString stringWithFormat:@"%@",[content.podcastDate objectAtIndex:indexPath.row]];
    [DynamicUI DynamicLabel:LabelDate textInput:strDate fontContent:[UIFont fontWithName:@"Droid Arabic Naskh" size:10.5] originX:15 originY:10 originW:275];

}

LabelTitle = (UILabel *) [cell.contentView viewWithTag:1];
LabelDate = (UILabel *) [cell.contentView viewWithTag:2];
calendarImage = (UIImageView *) [cell.contentView viewWithTag:3];

// Title
NSString *strTitle = [NSString stringWithFormat:@"%@",[content.podcastTitle objectAtIndex:indexPath.row]];
//[DynamicUI DynamicLabel:LabelTitle textInput:strTitle fontContent:[UIFont fontWithName:@"DroidArabicNaskh-Bold" size:12] originX:15 originY:30 originW:295];
    LabelTitle.text = strTitle;

// Date
NSString *strDate = [NSString stringWithFormat:@"%@",[content.podcastDate objectAtIndex:indexPath.row]];
//[DynamicUI DynamicLabel:LabelDate textInput:strDate fontContent:[UIFont fontWithName:@"Droid Arabic Naskh" size:10.5] originX:15 originY:10 originW:275];
    LabelDate.text = strDate;

return cell;
}
和didselectrow代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{   
UILabel *downloadingLabel  = [[UILabel alloc]initWithFrame:CGRectMake(300, 10, 100, 20)];
downloadingLabel.text = @"Downloading";
downloadingLabel.backgroundColor = [UIColor greenColor];
[[self.tableView cellForRowAtIndexPath:indexPath].contentView addSubview:downloadingLabel];
}

这条线是干什么的?[DynamicUIDynamicLabel:LabelTitle文本输入:标准字体fontContent:[UIFont fontWithName:@“DroidArabicNaskh Bold”大小:12]原件:15原件:30原件:295];您是否在if(cell==nil)子句中放置了日志以查看是否正在调用它?@Clement这是一种在标签中显示文本的方法。把它想象成setText:UILabel的方法。@rdelmar我刚才做过,它没有被调用!我做错了什么?如果在故事板中创建单元格,则dequeueReusableCellWithIdentifier:保证返回一个单元格,因此它永远不会为零。