Ios 当单击子索引XPath中的按钮时,SKSTableView的索引XPath出错
我使用的是SKSTableView控件。我在单元格上添加了按钮。当我单击按钮时,我遇到了一个问题,然后我得到了错误的行和子行Ios 当单击子索引XPath中的按钮时,SKSTableView的索引XPath出错,ios,objective-c,iphone,ipad,cocoapods,Ios,Objective C,Iphone,Ipad,Cocoapods,我使用的是SKSTableView控件。我在单元格上添加了按钮。当我单击按钮时,我遇到了一个问题,然后我得到了错误的行和子行 - (IBAction)btnPickListPressed:(id)sender { UIButton *btn=sender; PicklistTableViewCell *cell = (PicklistTableViewCell *)btn.superview.superview; NSIndexPath *indexPath = [se
- (IBAction)btnPickListPressed:(id)sender
{
UIButton *btn=sender;
PicklistTableViewCell *cell = (PicklistTableViewCell *)btn.superview.superview;
NSIndexPath *indexPath = [self.tblView indexPathForCell:cell];
NSLog("%@",indexPath.row);
NSLog("%@"indexPath.subRow);
}
首先复制下面的代码并打开SKSTableView.h
- (NSIndexPath *)correspondingIndexPathForRowAtIndexPath:(NSIndexPath *)indexPath
将其粘贴到SKSTableView.h中的@interface SKSTableView:UITableView
- (NSIndexPath *)correspondingIndexPathForRowAtIndexPath:(NSIndexPath *)indexPath
并将您的操作方法代码替换为:
UIButton *btn=sender;
PicklistTableViewCell *cell = (PicklistTableViewCell *)btn.superview.superview;
NSIndexPath *indexPath = [self.tblView indexPathForCell:cell];
NSIndexPath *correspondingIndexPath = [self.tblView correspondingIndexPathForRowAtIndexPath:indexPath];
NSLog("%@",correspondingIndexPath.row);
NSLog("%@"correspondingIndexPath.subRow);
首先复制下面的代码并打开SKSTableView.h
- (NSIndexPath *)correspondingIndexPathForRowAtIndexPath:(NSIndexPath *)indexPath
将其粘贴到SKSTableView.h中的@interface SKSTableView:UITableView
- (NSIndexPath *)correspondingIndexPathForRowAtIndexPath:(NSIndexPath *)indexPath
并将您的操作方法代码替换为:
UIButton *btn=sender;
PicklistTableViewCell *cell = (PicklistTableViewCell *)btn.superview.superview;
NSIndexPath *indexPath = [self.tblView indexPathForCell:cell];
NSIndexPath *correspondingIndexPath = [self.tblView correspondingIndexPathForRowAtIndexPath:indexPath];
NSLog("%@",correspondingIndexPath.row);
NSLog("%@"correspondingIndexPath.subRow);