Events UITableViewCell的句柄按钮事件?
我有一个带有一个按钮和一个uilabel的自定义TableViewCell。实际上,mi在哪里处理这个下载事件?如何处理 这是我的定制手机。我试着这样处理,但还是出错了Events UITableViewCell的句柄按钮事件?,events,uitableview,uibutton,Events,Uitableview,Uibutton,我有一个带有一个按钮和一个uilabel的自定义TableViewCell。实际上,mi在哪里处理这个下载事件?如何处理 这是我的定制手机。我试着这样处理,但还是出错了 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [downloadPageCell downloadSong:]: unrecognized selector sent to instance 0x
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [downloadPageCell downloadSong:]: unrecognized selector sent to instance 0x94b1490'
*** First throw call stack:
我的密码在这里
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
downloadPageCell *newCell = nil;
newCell = [tableView dequeueReusableCellWithIdentifier:identifier];
if(newCell == nil)
{
NSLog(@"newCell ===================");
NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"downloadPageCell" owner:self options:nil];
newCell = [ nibViews lastObject];
}
newCell.titleText.text=[URLTitle objectAtIndex:indexPath.row];
[newCell.downloadButton addTarget:self action:@selector(DOWNLOAD:) forControlEvents:UIControlStateNormal];
return newCell;
}
处理单元格中按钮事件的真正代码是什么
编辑
-(void)downloadButtonPressed:(UIButton*)sender
{
NSLog(@"download button pressed");
}
您可以通过以下方式为每个按钮指定标记:
newCell.downloadButton.tag=cell.indexPath.row
&在动作中,你可以找到按钮标签按下的按钮,并对所有按钮进行不同的动作。
您可以使用下面的方法来查找按钮
UIButton *btn1 = (UIButton *)sender;
if(btn1.tag==1) {
// call action for that first cell button
}
等等。但是我对所有按钮都有相同的操作,但只更改URL。但是这个操作不起作用,他们的代码有问题吗?[newCell.downloadButton addTarget:self action:@selector(downloadButtonPressed:)for controlEvents:UIControlEventTouchUpInside]@NeerajNeeru您的选择器方法在哪里,即在哪个类中查看我的编辑,没有什么我只是努力检查它是否工作按钮操作现在工作,我将选择器方法更改为-(void)downloadbutonpressed:(UIButton*)sender{NSLog(@“download button pressed”);}