2013-11-22 67 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元素。检查该复选框后,它的行为正常。

相关问题