ios - 如何通过点击UITableViewCell上的按钮来拿到它所在cell的位置
PHP中文网
PHP中文网 2017-04-17 17:37:32
0
3
516

这个是我的一个订单详情页面,我需要点击退款成功那个按钮跳入退款流程页面,但是数据是从我这个页面的一个数组拿的,所以我需要获取到点击的位置,我之前又在网上查过试过
// UITableViewCell cell = (UITableViewCell )[[but superview]superview];

NSIndexPath *indexPath = [self.tabView indexPathForCell:cell];
//
这个方法,可以并不能,希望有大神能帮我解决一下,如果可以的话,希望能解释一下,大神帮帮忙,谢谢
PHP中文网
PHP中文网

认证0级讲师

reply all(3)
小葫芦

Add a property to your Cell.h, NSIndexPath *indexPath; when assigning a value to the cell (assigning a value to the cell in the cellForRow or cellWillDisplay method), pass the indexPath of the TableView to the cell and let the cell save it. When the button on the cell is clicked, it is passed through the proxy. Then pass it to VC and it’s OK

刘奇

Hey. Are you not using MVC?

Then why does your cell know whether this line of payment is for testing products, nougat, or cocktails?

The header file of your cell should have a model attribute

When you click the button, check the model and you will know what this line is

PHPzhong

The tag of the button is set to the array subscript, and finally the data is found based on the subscript

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!