2013-01-11 31 views
1

當我nslog值設置它爲NULL後,任何字爲什麼?錯誤設置集合中的文本查看單元格

CustomCollectionVIewCell *cell =[[CustomCollectionVIewCell alloc]init]; 
NSString *name =[dict valueForKey:@"filterName"];//works 
[cell.labelDisplay setText:name];//does not 
NSLog(@"name = %@",cell.labelDisplay.text); 
cell.isSelected=NO; 
[_availableHealthFilters setObject:cell atIndexedSubscript:i]; 
+0

是你的名字顯示正確的值? –

+0

我猜你的名字變量是NULL。嘗試記錄該字符串。 – sosborn

+0

正確的名稱日誌 –

回答

1

在自定義單元格中初始化您的labelDisplay。

//customColectionCell.h 
@property(strong,nonomatic) NSString *labelText; 
-(void)setCellLabelText:(NSString *)labelText; 
//customCollectionCell.m 
-(id)init{ 
//init cellLabel and addSubView to customCell 

} 
//Than set label in custom method 
-(void)setCellLabelText:(NSString *)labelText{ 
_labelText = labelText; 
sefl.labelDisplay.text = labelText; 
} 
相關問題