Question

I currently have a custom timer class and a custom UITableviewCell, the timer has a set of delegate methods that fire based on the timer state, the custom cell has an instance of this timer class as a property and has the delegate methods set in the M file, however i notice they are not firing when the cell is assigned a timer and the timer is started.. my code is as follows:

TABLEVIEW CELL 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;

TABLEVIEW CELL 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

I know that these delegate methods work as i have tested by using an instance of this timer class in a viewcontroller and it's firing, is this not possible with a uitable view cell? Currently the timers are counting down in each cell but the delegate methods do not fire, any idea whats happening?

Était-ce utile?

La solution

In your AeroPressCell code, you haven't set the delegate of the timer class to the cell's instance. Try setting the timer's delegate like so - self.timer.delegate = self.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top