开发者

UIButton in UITableViewCell events not working

开发者 https://www.devze.com 2023-02-03 00:09 出处:网络
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 UITableViewC

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;
}


Seems the problem was to do with me updating the table cells too often, so this was interrupting any interaction with the cells themselves


have U placed this code int the table view.? tableView.delegate=self; tableView.dataSource=self;

Thanks, bharath

0

精彩评论

暂无评论...
验证码 换一张
取 消