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
.
Custom UITableViewCell running another classes delegate methods
-
13-06-2023 - |
문제
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?
해결책
제휴하지 않습니다 StackOverflow