2013-11-22 68 views
0

在問這個問題之前,我已經經歷了很多關於SO的問題。在StoryBoard中創建的自定義UITableViewCell重複UILabels的結果

我有一個問題,我在StoryBoard中創建了一個自定義的UITableView單元格。我已經分類了UITableViewCell和公開的屬性,以將我的各種組件鏈接到單元內。

我不是在創建或

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

添加任何成分的細胞,我只是用

[tableView dequeueReusableCellWithIdentifier:cleanseCell forIndexPath: indexPath]; 

調用重用的小區。我在單元上做了一些定製,但我沒有添加任何新東西。我只是修改一個圖像,一些標籤和一個文本字段。單元重用標識符在代碼和故事板中的組件上均正確設置。

問題是,當單元格被重用時,引擎蓋下的某個地方UILabels被複制。我還有一個UITextField - 它沒有這個問題。只有UILabel以某種方式重複。

因此,細胞首次顯示正確的信息。然後下一次該單元格創建它仍然很好。單元格第三次出現Overlapping UILabels。一個帶有新的文本,另一個帶有原始單元格的文本。無論如何,現在單元中有兩個UILabel,之前只有一個UILabel,我沒有在那裏添加它。

任何人都經歷過這個或有一些評論,使?

編輯:

這是我的UITableViewCell - 有沒有在執行其他比合成的屬性(甚至不要求反正)

#import <UIKit/UIKit.h> 

@interface SJCleanseNotificationCell : UITableViewCell 
@property (nonatomic)float openHeight; 
@property (nonatomic, strong)IBOutlet UIImageView *iconView; 
@property (nonatomic, strong)IBOutlet UILabel *dateTimeLabel; 
@property (nonatomic, strong)IBOutlet UILabel *titleLabel; 
@property (nonatomic, strong)IBOutlet UITextView *messageLabel; 
-(IBAction)dismiss:(id)sender; 
-(IBAction)activate:(id)sender; 
@end 

這是的cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cleanseCell = @"CleanseCell"; 

    NSDictionary *cleanse = sjTimer.cleanseNotification; 

    SJCleanseNotificationCell *cell; 
    if([_tableView respondsToSelector:@selector(dequeueReusableCellWithIdentifier:forIndexPath:)]) 
     cell = (SJCleanseNotificationCell*)[_tableView dequeueReusableCellWithIdentifier:cleanseCell forIndexPath: indexPath]; 
    else 
     cell = (SJCleanseNotificationCell*)[_tableView dequeueReusableCellWithIdentifier:cleanseCell]; 

    [cell.dateTimeLabel setText:[cleanse objectForKey:@"date"]]; 
    [cell.titleLabel setText:[cleanse objectForKey:@"title"]]; 
    [cell.messageLabel setText:[cleanse objectForKey:@"message"]]; 
    NSNumber *stage = (NSNumber*)[cleanse objectForKey:@"stage"]; 
    if(stage) 
     [cell.iconView setImage:[[SJCleanseTimer instance]bottleImageForCleanseStage:stage.integerValue]]; 
    cell.delegate = self; 
    cell.openHeight = 100; 
    return cell; 
} 
+0

你可以發佈您的自定義單元格類的一些代碼? –

+0

是 - 你有錯誤的地方...更多的代碼,請(所有表視圖代表+自定義類代碼)+故事板的截圖,如果你想更精確的幫助:) –

+0

你爲什麼要使用兩種不同的方法dequeueReusableCellWithIdentifier:forIndexPath:和dequeueReusableCellWithIdentifier: ?如果你只使用一個dequeueReusableCellWithIdentifier: – suhit

回答

0

這個問題是我有清除圖形上下文在上UILabe督察選中l元素。檢查該複選框後,它的行爲正常。

相關問題