在属性设置器中调用Delegate - 回调不起作用

时间:2013-07-07 07:59:54

标签: ios objective-c cocoa-touch uitableview

有一个自定义的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");
}

0 个答案:

没有答案
相关问题