2014-03-12 14 views
0

我現在有一個自定義計時器類和一個自定義的UITableViewCell,計時器有一組火基於定時器狀態委託方法,自定義單元格有這個定時器類的實例財產和擁有M檔設置的委託方法,但我注意到,當細胞被分配了一個定時器,定時器開始他們不燒..我的代碼如下:自定義的UITableViewCell運行的另一個類的委託方法

泰伯維傳感器h

#import <UIKit/UIKit.h> 
#import "TimerClass.h" 

@interface AeroPressCell : UITableViewCell <timerDelegate> 
@property (weak, nonatomic) IBOutlet UILabel *centerLabel; 
@property (weak, nonatomic) IBOutlet UILabel *rightLabel; 
@property (weak, nonatomic) IBOutlet UILabel *bottomLabel; 
@property (weak, nonatomic) IBOutlet UIImageView *cellImage; 
@property (weak, nonatomic) IBOutlet TimerClass *timer; 

泰伯維小區M

#import "AeroPressCell.h" 

@implementation AeroPressCell 

@synthesize cellImage; 
@synthesize centerLabel; 
@synthesize bottomLabel; 
@synthesize rightLabel; 
@synthesize timer; 

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 
{ 
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) { 
     // Initialization code 
    } 
    return self; 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated 
{ 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 

#pragma mark Timer Delegate 
#pragma mark - 

- (void)timerStarted{ 
    NSLog(@"STARTED"); 

} 

- (void)timerTick{ 


} 

- (void)timerPaused{ 
    NSLog(@"PAUSED"); 

} 

- (void)timerResumed{ 


} 

- (void)timerFinished{ 

    NSLog(@"FINISHED"); 
} 


@end 

我知道這些委託的方法工作,因爲我已經在一個視圖控制器使用這個計時器類的一個實例測試,它的射擊,這是無法實現的uitable觀察室?目前定時器在每個單元中倒計時,但委託方法不會觸發,有什麼想法會發生什麼?

回答

0

在你AeroPressCell的代碼,你有沒有計時器類的委託設置爲電池的實例。嘗試設置計時器的代表像這樣 - self.timer.delegate = self

+0

感謝的是,這是第二次我忘了設定那該死的代表:)有一點要注意委託必須在設置: - 動畫(BOOL):(無效)的setSelected:選擇動畫(BOOL) { [super setSelected:selected animated:animated]; //配置視圖在的UITableViewCell M檔的選擇狀態 } – SmokersCough

相關問題