我正在开发一个 Messenger 应用程序。我有一个带有自定义单元格的表格 View ,其中包含一个 ImageView 和几个标签。
我想在点击不同的 UI 元素时加载不同的 Controller 。具体来说,我希望在点击 imageView 时加载 controllerA,在选择行的其余部分时加载 controllerB。
我在 imageview 顶部放置了一个按钮,并制作了一个 customcellclass 委托(delegate),以便在借助该按钮点击 imageview 时通知我的 tableviewcontroller - 现在我应该如何获取点击行 imageView 的索引路径??
//我的自定义类方法
-(IBAction)loadProfileButtonTapped:(id)sender{
[self.loadProfileDelegate takeMeToProfile];
}
//我正在我的tableview controller中实现这个方法
-(void)takeMeToProfile{
//need indexpath here
}
最佳答案
假设您的 TableView 名为 tableView,并且您在获取发件人的方法中获取了点击图像的引用:
CGPoint imagePosition = [sender convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:imagePosition];
关于ios - 如何获取所选行的索引路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28577593/