iOS自定义UITableView单元格
问题描述:
我使用自定义样式的UITableView我在故事板中有一个红色警告(未分类编译失败)。iOS自定义UITableView单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"Cell"];
codeLabel.text = [[courseMURArray objectAtIndex:indexPath.row] objectForKey:@"courseCode"];
nameLabel.text = [[courseMURArray objectAtIndex:indexPath.row] objectForKey:@"courseName"];
houreLabel.text = @"3";
priceLabel.text = @"0.000";
return cell;
}
答
试试看这样的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"YourCell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc]init]; //or some other init, don't have a Mac nearby, don't remember it by heart
}
self.codeLabel.text = [[courseMURArray objectAtIndex:indexPath.row] objectForKey:@"courseCode"];
self.nameLabel.text = [[courseMURArray objectAtIndex:indexPath.row] objectForKey:@"courseName"];
self.houreLabel.text = @"3";
self.priceLabel.text = @"0.000";
[cell addSubview:self.codeLabel];
[cell addSubview:self.nameLabel];
[cell addSubview:self.houreLabel];
[cell addSubview:self.priceLabel];
return cell;
}
希望它可以帮助
答
你的问题还不清楚,但我猜你的应用程序未能建立。请看下面的问题的可能解决方案和一些步骤来帮助您找到问题。
您能否让您的问题更清楚?我不太明白你在问什么。 – pasawaya
如果您回答自己的问题,请在答案区域添加答案。 –