How to get UITableView from UITableViewCell?
来源:互联网 发布:北京尚学堂 java ppt 编辑:程序博客网 时间:2024/04/30 23:50
参考自:http://stackoverflow.com/questions/15711645/how-to-get-uitableview-from-uitableviewcell
通过UITableViewCell得到其UITableView
id view = [tableViewCellInstance superview];while (view && [view isKindOfClass:[UITableView class]] == NO) { view = [view superview]; }UITableView *tableView = (UITableView *)view;
通过UITableViewCell上的子View来获得其对应的UITableViewCell
参考自:http://stackoverflow.com/questions/18962771/getting-uitableviewcell-with-superview-in-ios-7
UITableViewCell *cell = [button findSuperViewWithClass:[UITableViewCell class]]
@interface UIView (SuperView)- (UIView *)findSuperViewWithClass:(Class)superViewClass;@end@implementation UIView (SuperView)- (UIView *)findSuperViewWithClass:(Class)superViewClass { UIView *superView = self.superview; UIView *foundSuperView = nil; while (nil != superView && nil == foundSuperView) { if ([superView isKindOfClass:superViewClass]) { foundSuperView = superView; } else { superView = superView.superview; } } return foundSuperView;}@end
或者
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tableView];NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition];UITableViewCell *cell = (UITableViewCell*)[self.tableView cellForRowAtIndexPath:indexPath];
0 0
- How to get UITableView from UITableViewCell?
- How to get UITableView from UITableViewCell?
- How to get file from classpath
- How to get parameters from the URL?
- How to get IHTMLDocument2 from a HWND
- How to get bean from tag component
- How to get byte array from imageview
- How to get kernel messages from Android?
- How to get source code from APK
- How to switch from POST to GET in PHP CURL
- [VB]How to get index from combo box
- How to get groups, users from Active Directory with C#
- How to get an X11 Window from a Process ID?
- how to get toolchain from android source -make windows sdk
- How to get trace file from getbfno.sql gettrcname.sql
- How to get AVFrame(ffmpeg) from NSImage/UIImage
- How to get file extension from string in C++
- how to get preloader and dsp_bl from mtk phone?
- 为什么唱吧iOS 6.0选择了Mantle
- linux常用命令
- Python实现的基于ADB的Android远程工具
- android更新错误
- mysql_connect和mysql_pconnect的区别
- How to get UITableView from UITableViewCell?
- POJ3107——Godfather
- 求数组的最大子段和,动态规划 时间复杂度O(n)
- linux查看内存
- 一种非常简单有效的基于格子的寻路算法
- struts2国际化---输出带有占位符的国际化信息以及包范围、Action范围资源文件访问
- C#基础 之 初识委托delegate
- 对-128的补码的理解
- IOS开发----CMDeviceMotion陀螺仪的使用