如何获取UITableView中cell的frame值
2014-12-24 21:28
375 查看
如何获取UITableView中cell的frame值
这个可以用来处理UITableView弹出键盘的问题
本人视频教程系类 iOS中CALayer的使用
效果:
源码:
关键的地方:
这个可以用来处理UITableView弹出键盘的问题
本人视频教程系类 iOS中CALayer的使用
效果:
源码:
// // ViewController.m // TableViewCellFrame // // Created by YouXianMing on 14/12/24. // Copyright (c) 2014年 YouXianMing. All rights reserved. // #import "ViewController.h" static NSString *YOU_XIAN_MING = @"REUSED_FLAG"; @interface ViewController ()<UITableViewDataSource, UITableViewDelegate> @property (nonatomic, strong) UITableView *tableView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // 关闭状态栏 [UIApplication sharedApplication].statusBarHidden = YES; // 创建tableView [self createTableView]; } #pragma mark - TableView相关 - (void)createTableView { self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; self.tableView.delegate = self; self.tableView.dataSource = self; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:YOU_XIAN_MING]; [self.view addSubview:self.tableView]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 20; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:YOU_XIAN_MING]; cell.textLabel.text = [NSString stringWithFormat:@"YouXianMing - %02ld", (long)indexPath.row]; cell.textLabel.textColor = [UIColor grayColor]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // 获取对应cell的rect值(其值针对于UITableView而言) CGRect rect = [self.tableView rectForRowAtIndexPath:indexPath]; // 做动画效果 NSLog(@"%@", NSStringFromCGRect(rect)); [self.tableView setContentOffset:CGPointMake(rect.origin.x, rect.origin.y) animated:YES]; } @end
关键的地方:
相关文章推荐
- UITableview中如何获取点中的是哪一个cell
- 如何获取uitableview中最上面的可见cell的索引
- UITableView如何获取所有的cell
- UITableView如何让cell的分割线左边不缩进
- 如何让 UITableView 的 headerView跟随 cell一起滚动
- UITableView获取cell的indexPath
- UITableViewCell 四种样式的具体显示效果&&获取可见UITableView 中的所有cell
- 如何去掉grouped样式UITableView中cell的边框和背景
- iOS开发-- 如何让 UITableView 的 headerView跟随 cell一起滚动
- UITableView获取当前选中的cell
- 获取UITableView 的cell 及其cell上的controll
- 如何让 UITableView 的 headerView跟随 cell一起滚动
- 获取UITableView 的cell 及其cell上的controll
- (转) 如何让 UITableView 的 headerView跟随 cell一起滚动
- Uitableview中didSelectRowAtIndexPath常用的获取cell信息的方法
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)
- 如何让 UITableView 的 headerView跟随 cell一起滚动
- ios UITableView 获取点击cell对象
- UITableView获取cell的row值