1

UILabel在情节提要中设计的原型单元中有 2 秒。两者都有其指定的tag编号(1000 和 1001)。当我编写该tableView cellForRowAtIndexPath:方法时,似乎其中一个标签正在接收相关NSString的,而另一个则没有。

这是代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {           

    static NSString *CellIdentifier = @"ContentCell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    ContentObject * contentObject =  [contentPackageManager.contentObjectsArray objectAtIndex:[indexPath row]];
//contentPackageManager is a class that holds an NSArray of ContentObjects (it does a few other things, but they are not relevant for this method...)
//ContentObject is a class that holds several attributs such as: NSString*name, NSString*type, etc...

    UILabel *nameLabel = (UILabel *)[cell viewWithTag:1000];
    nameLabel.text = contentObject.name; //this line works OK

    UILabel * typeLabel = (UILabel *)[cell viewWithTag:1001]; 
    typeLabel.text = contentObject.contentType; //this is the PROBLEMATIC one - no effect on the actual UILabel

    return cell;           
}

有人熟悉这个问题吗?

难道我做错了什么?

4

1 回答 1

0

请检查是否 contentObject.contentType不为空。

于 2012-08-29T13:46:55.777 回答