views:

188

answers:

1

i am trying to add a button to the tableview and no matter what frame i specify the button is not visible. This is a custom UITableViewCell and I am adding the button in the code rather than in the xib file is so that I can click on the button and perform an action which is not didSelectRowAtIndexPath: I have the following code in cellForRowAtIndexPath: What am I missing?

UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    button.frame = bframe;
    button.userInteractionEnabled = YES;
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [cell.contentView addSubview:button];
    return cell;
A: 

try this

UIButton *button = [[UIButton buttonWithType:UIButtonTypeDetailDisclosure] retain];

Nnp
thanks for your reply. this doesn't work. buttonWithType does the allocation and autoRelease for you, so I don't how this is any different from what I do.
Dave
i have update code in my answer,
Nnp