【发布时间】:2013-11-04 04:09:32
【问题描述】:
我在 tableViewCell 中创建的 UILabel 有一些问题。所以我有带有Textlabel、详细文本和我第三个创建的单元格标签的tableView。所以我从 JSON 获取信息并粘贴到第三个标签,所以它的结果:
但是当我尝试滚动表格时,时间文本出现了一些问题:
所以当我为这个标签添加 UIColor 白色作为背景时,我没有这个白痴在数字后面。请帮忙看看我做错了什么?
我添加我的代码表视图
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(! cell)
{
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]autorelease];
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]autorelease];
}
cell.textLabel.text = [[array objectAtIndex:indexPath.row]objectForKey:@"song"];
cell.detailTextLabel.text = [[array objectAtIndex:indexPath.row]objectForKey:@"artist"];
UILabel *mainLabel;
//frame=CGRectMake(Позиция по X, Позиция по Y, Размеры ширина, Раздел высота)
mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(70, 58, 220.0, 15.0)] autorelease];
mainLabel.font = [UIFont systemFontOfSize:14.0];
mainLabel.textColor = [UIColor blackColor];
[cell.contentView addSubview:mainLabel];
mainLabel.text = [[array objectAtIndex:indexPath.row]objectForKey:@"start"];
[cell.imageView setImageWithURL:[NSURL URLWithString:[[array objectAtIndex:indexPath.row] objectForKey:@"image"]] placeholderImage:[UIImage imageNamed:@"1@2x.png"]];
cell.textLabel.textColor = [UIColor whiteColor];
cell.detailTextLabel.textColor = [UIColor whiteColor];
mainLabel.backgroundColor = [UIColor clearColor];
mainLabel.textColor = [UIColor whiteColor];
[tableTrack setBackgroundView:nil];
[TrackTableView setBackgroundView:nil];
tableTrack.backgroundColor = [UIColor clearColor];
TrackTableView.backgroundColor = [UIColor clearColor];
UIFont *f = [UIFont fontWithName:@"Helvetica 35 Thin" size:18.0f];
cell.textLabel.font = f;
UIFont *f2 = [UIFont fontWithName:@"Helvetica 35 Thin" size:14.0f];
cell.detailTextLabel.font = f2;
UIFont *f3 = [UIFont fontWithName:@"Helvetica 35 Thin" size:14.0f];
mainLabel.font = f3;
self.tableTrack.separatorStyle = UITableViewCellSeparatorStyleNone;
UIView *separatorView = [[UIView alloc] initWithFrame:CGRectMake(10, 74, 1024, 1)];
separatorView.layer.borderColor = [UIColor whiteColor].CGColor;
separatorView.layer.borderWidth = 0.5;
[cell.contentView addSubview:separatorView];
self.TrackTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
return cell;
}
【问题讨论】:
-
请提供数据源委托方法!
-
你想看我的代码项目吗?
-
不只是 cellForRowatIndexPath 委托方法
标签: ios json xcode uitableview cell