I’m using two frameworks to slide UITableViewCells of the TableView. Those are: DMSlidingCell and LRSlidingTableViewCell.
I’m trying to put a button in the background view of UITableViewCell (the view which is shown when the Cell disappears) and I succeed in doing so – the button shows up. But this button is either inactive or it disables the sliding behaviour of the cell.
I’m wondering how is it done. I’m basically doing this in the custom cell class:
-(void) addButtonToCell
{
UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(95, 25, 60, 44);
btn.tag = 1234;
[btn setTitle:@"Hi" forState:UIControlStateNormal];
[btn addTarget:self
action:@selector(tryOut)
forControlEvents:UIControlEventTouchDown];
[self.backgroundView addSubview:btn];
}
And I add the button to the view like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"CELL_IDENTIFIER";
LRSlidingTableViewCell *cell = (LRSlidingTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[[LRSlidingTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.textLabel.text = [NSString stringWithFormat:@"Cell %d", indexPath.row];
cell.delegate = self;
[cell addButtonToCell];
return cell;
}
Any ideas on what could be wrong? Thanks in advance!
try
see you!