iOS開發之根據按鈕確定點擊的section 和row

  分組的tableview cell上面有按鈕,根據按鈕確定點擊的是哪一組的哪一行。對於初學者來說不好判斷,那麼下面就來跟大家分享一下如何實現吧。

  cell 方法裏面添加

  [cell.pingjiaBtn addTarget:self action:@selector(didPingJiaButton: event:) forControlEvents:UIControlEventTouchUpInside];

  按鈕點擊事件

  - (void)didPingJiaButton:(UIButton *)sender event:(id)event{

  NSSet *touches=[event allTouches];

  UITouch *touch=[touches anyObject];

  CGPoint cureentTouchPosition=[touch locationInView:tableviews];

  //得到indexPath

  NSIndexPath *indexPath=[tableviews indexPathForRowAtPoint:cureentTouchPosition];

  NSDictionary *dic = [NSDictionary dictionaryWithDictionary:self.listarr[indexPath.section][indexPath.row]];

  ShoppingPingFenViewController *view = [[ShoppingPingFenViewController alloc]init];

  view.tidStr = String(dic[@"tid"]);

  view.gidStr = String(dic[@"gid"]);

  view.cidStr = String(dic[@"cid"]);

  view.imgStr = String(dic[@"goods_pic"]);

  view.hidesBottomBarWhenPushed = YES;

  [self.navigationController pushViewController:view animated:NO];

  }

  以上就是爲大家分享的內容了,如果還是存在有不理解,或者有不懂的地方,都是可以留言諮詢的。

  本文由專業的鄭州app開發公司燚軒科技整理髮布,如需轉載請註明出處。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章