【发布时间】:2011-01-08 18:28:28
【问题描述】:
我在网上看到了这个问题,但列出的解决方案都不适合我!
我已将 UIButton 添加到 IB 中的 UITableViewCell。我已经为 UITableViewCell 分配了一个自定义 UITableViewCell 类。我的自定义 UITableViewCell 类有一个 IBAction,它连接到 Touch Up Inside 事件(我尝试过其他事件,它们都不起作用),但从未调用 IBAction 函数!
UITableViewCell 中没有其他内容,我已将 UIButton 直接添加到 Content View 中。一切都启用了用户交互!就这么简单,我没有什么复杂的事情发生!
什么是 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;
}
【问题讨论】:
-
您的
IBAction方法是在您的单元子类中还是在您的视图控制器中定义的?如何在表格视图中初始化单元格? -
我已编辑问题以包含您的问题!谢谢
标签: iphone uitableview uibutton