iOS开发 在cell中找到它在tableView中的indexPath
来源:互联网 发布:淘宝库房分拣员累吗 编辑:程序博客网 时间:2024/05/21 03:25
1.这个方法是在cell中用的(比如我在cell中写了一个button的点击方法,我想在点击方法中找到cell的indexPath并通过通知传出去,在其他任何地方用)
UITableView *tableView; float Version=[[[UIDevice currentDevice] systemVersion] floatValue];//(设备判断) if(Version>=7.0){ tableView = (UITableView *)self.superview.superview; }else{ tableView=(UITableView *)self.superview; } NSIndexPath *indexPath= [tableView indexPathForCell:self]; NSNotification * notification = [NSNotification notificationWithName:@"clickNumber" object:self userInfo:@{@"value":[NSString stringWithFormat:@"%ld",(long)[indexPath row]]}]; [[NSNotificationCenter defaultCenter] postNotification:notification];
2.接值
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickNumber:) name:@"clickNumber" object:nil];- (void)clickNumber:(NSNotification *)notification{ NSString *string = [notification valueForKey:@"userInfo"][@"value"]; NSLog(@"%@",string);}
0 0
- iOS开发 在cell中找到它在tableView中的indexPath
- 怎样在ios开发中设置tableview的cell颜色
- 根据用户在tableview中点击(触摸)cell的自定义accessoryButton获得其indexpath
- 根据用户在tableview中点击(触摸)cell的自定义accessoryButton获得其indexpath
- iOS 设置cell的在tableView中的间隔距离
- iOS 通过cell找到TableView
- iOS中获取用户所点击的位置信息,并通过这个位置信息得到tableView的中的cell的indexPath.section
- 【iOS开发】通过cell获取indexPath
- iOS tableView 在最后插入Cell
- 在tableview 中的代理调用 [tableView cellForRowAtIndexPath:indexPath] 提示内存错误
- IOS开发 tableview中cell的用法
- IOS开发 tableview中cell的用法
- IOS开发 tableview中cell的用法
- IOS开发 tableview中cell的用法
- 通过cell中的元素获取cell的indexPath以及长按tableview获取选中cell的indexPath
- UIMenuItem在tableview中对应cell显示
- 在cell中获取自己的tableView
- iOS 开发,UITableViewController中手势关闭cell中的键盘。且不影响tableView中的 didSelectRowAtIndexPath 方法。
- thinkphp命名空间
- MySQL索引原理及慢查询优化MySQL索引原理及慢查询优化
- SDN资料整理
- hyperledger fabric PBFT算法简要解析
- Mysql 多表查询基本操作 第五更
- iOS开发 在cell中找到它在tableView中的indexPath
- Shell 全局替换
- 硬盘划分原理与存取机制
- laravel excel 导入
- 【淘淘】拦截器原理、实现
- 截屏应注意的细节和尝试(导出的图片一片黑色)
- OpenStack 镜像服务Glance [三]
- Ugly Number II
- ogre 引擎 框架追踪 第三章 资源加载之虚加载