1
更新我在故事板中設計的原型單元中有2 UILabel
s。兩者都有其指定的tag
號碼(1000和1001)。當我編寫tableView cellForRowAtIndexPath:
方法時,似乎其中一個標籤正在接收相關的NSString
,另一個則沒有。原型單元中的UILabel沒有從代碼
下面是代碼:
- (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不是NULL(我NSLogged它),而typeLabel.text是NULL。 –