如何根据indexPath获取单元格文本?
我有一个包含超过 5 个 UITabBarItems 的 UITabBarController,因此 moreNavigationController 可用。
在我的 UITabBarController Delegate 中,我执行以下操作:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
//do some stuff
//...
UITableView *moreView = (UITableView *)self.tabBarController.moreNavigationController.topViewController.view;
moreView.delegate = self;
}
我想实现一个 UITableViewDelegate,以便我可以捕获所选的行,设置自定义视图属性,然后推送视图控制器:
- (void)tableView:(UITableView *)tblView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//how can I get the text of the cell here?
}
我需要在以下情况下获取单元格的文本:用户点击一行。我怎样才能做到这一点?
I have a UITabBarController with more than 5 UITabBarItems so the moreNavigationController is available.
In my UITabBarController Delegate I do the following:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
//do some stuff
//...
UITableView *moreView = (UITableView *)self.tabBarController.moreNavigationController.topViewController.view;
moreView.delegate = self;
}
I want to implement a UITableViewDelegate so I can capture the row that was selected, set a custom view property and then push the view controller:
- (void)tableView:(UITableView *)tblView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//how can I get the text of the cell here?
}
I need to get the text of a cell when the user taps on a row. How can I accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更好的解决方案是维护单元格数组并直接在此处使用它
A better Solution is to maintain Array of cell and use it directly here
Swift 5
您始终可以根据
IndexPath
从UITableVIew
或UICollectionView
获取您的cell
像这样:Swift 5
You can always get your
cell
fromUITableVIew
orUICollectionView
based onIndexPath
like this: