通过操作表传递索引路径
我有一个表视图控制器,当您选择一行时,会出现一个操作表。然后用户选择一个选项,然后调用 -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
。但到那时我不知道首先选择哪个表视图单元格来显示操作表。有没有办法通过操作表传递索引路径?
I have a table view controller and when you select a row an action sheet appears. Then the user would select an option, followed by -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
been called. But by that point I don't know which table view cell was selected to bring up the action sheet in the first place. Is there a way to pass an index path through an action sheet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于 UIActionsheet 是 UITableView 的子级,您可以使用 tag 属性来存储 indexPath.Row。
我假设你的桌子只有一个部分。但是,如果您的表有多个部分,那么您可以创建 2 个类级别变量来保留 indexPath.row 和 indexPath.column,或者您可以自定义 UIActionSheet 并将相应的值分配给操作表类的属性。
即使您的 tableViewDelegate 和操作表委托不同,自定义操作表也会为您提供帮助。
如果您在编写代码时需要帮助,请发帖。
As UIActionsheet is child of UITableView you can use tag property to store the indexPath.Row.
I am assuming that your table has only one section. But if your table has more than one section then you can either make 2 class level variable to preserve the indexPath.row and indexPath.column OR you can customize UIActionSheet and assign respective value to properties of your action sheet class.
customizing action sheet will help you even when your tableViewDelegate and action sheet delegate are different.
Please post if you need help in writing code.
在显示操作表时保存索引路径,然后单击操作表的 clickedButtonAtIndex
将选择您的行。
这里 savedIndexPath 是您最后选择的表格视图
Save the index path while displaying action sheet and then click on clickedButtonAtIndex of your action sheet
which will select your row.
Here savedIndexPath is your last selection of your table view