Ich habe eine Tableview AdminOrderViewController
genannt und es hat customcell StepperProgressCell
genannt.CustomTableCell Delegierter
Diese customcell hat eine benutzerdefinierte UIView AYStepperView
genannt. Es gibt eine Schaltfläche in diesem UIView und ich habe einen Delegaten darauf implementiert, wann immer es geklickt wird und ich möchte diese Delegate clicked
Methode auf AdminOrderViewController
aufgerufen werden.
Aber ich weiß nicht, wie cell.delegate hinzufügen ??
AdminOrderViewController.m
@interface AdminOrderViewController : UIViewController <AYStepperViewDelegate>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"StepperProgressCell";
StepperProgressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (!cell) {
cell = [[StepperProgressTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
//cell.stepperView.delegate= ???
return cell;
}
- (void)clicked
{
// is not getting called?
}
StepperProgressTableViewCell.m
@interface StepperProgressTableViewCell()
@property (nonatomic) AYStepperView *stepperView;
@property (nonatomic) NSUInteger currentIndex;
@property (nonatomic) NSUInteger currentStep;
@property (nonatomic) UIView *containerView;
@end
@implementation StepperProgressTableViewCell
@synthesize stepperView;
- (void)awakeFromNib {
[super awakeFromNib];
[self setUpViews];
}
- (void)setUpViews {
self.stepperView = [[AYStepperView alloc]initWithFrame:CGRectMake(0, 0 , [[UIScreen mainScreen] bounds].size.width, kFormStepperViewHeight) titles:@[@"Processing",@"Ready",@"Delivered", nil)]];
[self addSubview:self.stepperView];
}
AYStepperView.m
@protocol AYStepperViewDelegate <NSObject>
@required
- (void)clicked;
@end
- (void)buttonPressed:(UIButton *)sender {
[stepperDelegate clicked];
}
UPDATE:
cell.stepperView.delegate = Selbst in Ihrem cellForRow nur wo Sie es kommentiert haben –
Zelle Zugriff nicht auf stepperView ?? – hotspring
, was Sie meinen, bitte erklären Sie sich, wenn Ihre stepperView Eigentum Ihrer Zelle ist, dass Sie dies ohne Probleme tun können, und Ihre steeperView haben eine id Delegat –