有一个自定义的tableview单元,它委托两个方法,第一个工作正常,但第二个(restoreButtonState:)
不工作,设置为委托的类中的委托方法不会被调用。
@protocol CustomTableViewCellDelegate <NSObject>
@required
- (void) storeButtonState:(ButtonState)state forCell:(CustomTableViewCell *)cell withButton:(UIButton *)sender;
- (void) restoreButtonState: (UIButton *)button forCell:(CustomTableViewCell *)cell;
@end
@interface CustomTableViewCell : UITableViewCell
// Delegate
@property (assign) id <CustomTableViewCellDelegate> delegate;
// Set in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
@property (strong, nonatomic)NSIndexPath *indexPath;
@property (weak, nonatomic) IBOutlet UILabel *mainLabel;
@property (weak, nonatomic) IBOutlet UILabel *numberLabel;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *spinner;
@property (weak, nonatomic) IBOutlet UIButton *tagLectureButton;
@property UIButton *tagLectureButton
的setter正在调用我在委托中实现的回调方法。但没有任何反应,任何想法为什么会这样?
//Setter
- (void)setTagLectureButton:(UIButton *)tagLectureButton
{
NSLog(@" tagLectureButton setter called");
[self.delegate restoreButtonState:tagLectureButton forCell:self];
}
// Delegated method - does not get called
- (void) restoreButtonState:(UIButton *)button forCell:(CustomTableViewCell *)cell
{
NSLog(@"$$$ Delegated method: restoreButtonState called");
}