UIButton in UITableViewCell events not working

Posted by Tristan on Stack Overflow See other posts from Stack Overflow or by Tristan
Published on 2011-01-08T18:28:28Z Indexed on 2011/01/09 0:54 UTC
Read the original article Hit count: 777

Filed under:
|
|

I see this problem all over the net, and none of the solutions listed work for me!

I have added UIButton to a UITableViewCell in IB. I have assigned a custom UITableViewCell class to the UITableViewCell. My custom UITableViewCell class has an IBAction that im connecting to the Touch Up Inside event (I have tried other events they all don't work) but the IBAction function is never called!

There is nothing else in the UITableViewCell, I have added the UIButton directly into the Content View. And everything has user interaction enabled! It is as simple as that I have nothing complex going on!

What is is about a UITableViewCell that stops buttons working?

EDIT: By request the code where I initialize my UITableViewCells the custom class is called DownloadCell

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellIdentifier = @"DownloadCell";

    DownloadCell *cell = (DownloadCell *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) 
    {
        UIViewController * cellController = [[UIViewController alloc] initWithNibName:@"DownloadCell" bundle:nil];
        cell = (DownloadCell *)cellController.view;
        [cellController release];
    }

    SoundLibrarianIPhoneAppDelegate * del = (SoundLibrarianIPhoneAppDelegate *)[UIApplication sharedApplication].delegate;

    DownloadQueue * dq = del.downloadQueue;

    DownloadJob * job = [dq getDownloadJob: indexPath.row];
    [job setDelegate:self];

    SoundInfo * info = [job sound];

    NSArray * seperated = [info.fileName componentsSeparatedByString: @"."];
    NSString * displayName = [seperated objectAtIndex:0];
    displayName = [displayName stringByReplacingOccurrencesOfString:@"_" withString:@" "];
    displayName = [displayName capitalizedString];

    [cell.titleLabel setText: displayName];
    cell.progressBar.progress = job.percentCompleted;
    [cell.progressLabel setText: [job getProgessText]];

    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.userInteractionEnabled = YES;

    [cell setDelegate:self];

    return cell;
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitableviewcell