2011-01-08 46 views
1

我在網上看到這個問題,並沒有列出的解決方案爲我工作!UIButton在UITableViewCell事件不起作用

我已將UIButton添加到IB中的UITableViewCell。我已經爲UITableViewCell分配了一個自定義的UITableViewCell類。我的自定義UITableViewCell類有一個IBAction,它可以連接到Touch Up Inside事件(我嘗試了其他事件,但它們都不起作用),但是IBAction函數從未被調用!

UITableViewCell中沒有其他東西,我已經將UIButton直接添加到內容視圖中。一切都啓用了用戶交互!這很簡單,我沒有任何複雜的事情發生!

什麼是關於一個UITableViewCell停止按鈕的工作?

編輯:根據要求,我初始化我UITableViewCells代碼自定義類被稱爲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; 
} 
+0

是您的小區內定義了`IBAction`方法子類還是在你的視圖控制器?你如何初始化你的表格視圖中的單元格? – BoltClock 2011-01-08 18:29:24

回答

1

看來問題是我怎麼辦更新表細胞過於頻繁,所以這是中斷與細胞本身的任何交互

0

具有u放在這個代碼INT表視圖? tableView.delegate = self; tableView.dataSource = self;

感謝, 巴拉斯