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開發公司燚軒科技整理髮布,如需轉載請註明出處。