Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Events UITableViewCell的句柄按钮事件?_Events_Uitableview_Uibutton - Fatal编程技术网

Events UITableViewCell的句柄按钮事件?

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

我有一个带有一个按钮和一个uilabel的自定义TableViewCell。实际上,mi在哪里处理这个下载事件?如何处理

这是我的定制手机。我试着这样处理,但还是出错了

*** 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”);}