Ios 如何以编程方式为SWTableViewCell库创建子类?(滑动单元格)

Ios 如何以编程方式为SWTableViewCell库创建子类?(滑动单元格),ios,iphone,objective-c,uitableview,Ios,Iphone,Objective C,Uitableview,我想用它实现SwipeCell。我想创建SWTableViewCell的子类,以便更轻松地进行自定义。我已经做了,但不起作用。我想我忘了什么,我的意思是,刷卡不工作,但我可以看到手机 下面是我的子类代码: h 你可以试试 [cell setCellHeight:_customHeight]; 如果单元格高度不是默认值 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentif

我想用它实现SwipeCell。我想创建
SWTableViewCell
的子类,以便更轻松地进行自定义。我已经做了,但不起作用。我想我忘了什么,我的意思是,刷卡不工作,但我可以看到手机

下面是我的子类代码:

h

你可以试试

[cell setCellHeight:_customHeight]; 
如果单元格高度不是默认值

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{    
    UITableView * table= nil;
    WPUserPlanCell *cell = (WPUserPlanCell *)self;
    if([cell isKindOfClass:[UITableViewCell class]]){
        table = (UITableView *)cell.superview;
        if(IS_OS_7_OR_LATER){
            table = (UITableView *)cell.superview.superview;
        }
    }
    NSMutableArray *rightUtilityButtons = [NSMutableArray new];

    [rightUtilityButtons sw_addUtilityButtonWithColor:
     [UIColor colorWithRed:1.0f green:0.231f blue:0.188 alpha:1.0f] title:@"Delete"];

     self = [super initWithStyle:style
                                  reuseIdentifier:reuseIdentifier
                              containingTableView:table
                               leftUtilityButtons:nil
                              rightUtilityButtons:rightUtilityButtons];

    if (self) 
    {
        CGRect labelFrame = UIEdgeInsetsInsetRect(self.bounds, titleLabelInsets);
        labelFrame.size = kLabelSize;

        tileLabel = [[WPCustomLabel alloc] initWithFrame:labelFrame];
        [tileLabel setTextColor:[UIColor blackColor]];
        [tileLabel setFont:[UIFont systemFontOfSize:14]];
        [tileLabel setBackgroundColor:[UIColor clearColor]];
        tileLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:tileLabel];

        labelFrame.size.width = self.bounds.size.width - kLabelSize.width;
        labelFrame.origin.x = CGRectGetMaxX(labelFrame) + 15;

        dateLabel = [[WPCustomLabel alloc] initWithFrame:labelFrame];
        [dateLabel setTextColor:[UIColor orangeColor]];
        [dateLabel setFont:[UIFont systemFontOfSize:14]];
        [dateLabel setBackgroundColor:[UIColor clearColor]];
        dateLabel.textAlignment = NSTextAlignmentRight;
        [self addSubview:dateLabel];
    }
    return self;
}

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    if (aTableView == self.tableView) {

        Plan *plan = (Plan *)[self.fetchedResultsController objectAtIndexPath:indexPath];

        // Creating Reusable Cell
        WPUserPlanCell *cell = (WPUserPlanCell *)[aTableView dequeueReusableCellWithIdentifier:PlanCellIdentifier];
        if (cell == nil)
        {
            // INIT REUSABLE CELL
            cell = [[WPUserPlanCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:PlanCellIdentifier] ;
            cell.delegate = self;
        }

        [cell configureCellWithTitle:plan.name andDate:plan.date];
        return cell;
    }
    return nil;
}
[cell setCellHeight:_customHeight];