Ios 原型单元中的UILabel不会从代码更新
我在故事板中设计的原型单元中有2个Ios 原型单元中的UILabel不会从代码更新,ios,uitableview,storyboard,uilabel,Ios,Uitableview,Storyboard,Uilabel,我在故事板中设计的原型单元中有2个UILabels。两者都有其指定的标签编号(1000和1001)。当我编写tableView cellforrowatinexpath:方法时,似乎其中一个标签正在接收相关的NSString,而另一个没有 代码如下: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { sta
UILabel
s。两者都有其指定的标签
编号(1000和1001)。当我编写tableView cellforrowatinexpath:
方法时,似乎其中一个标签正在接收相关的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;
}
有人熟悉这个问题吗
我做错什么了吗?请检查
contentObject.contentType
是否不为空。contentObject.contentType不为空(我记录了它),而typeLabel.text为空。