如何获取UITableView中cell的frame值

这个可以用来处理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 ;
}
- (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的frame值的更多相关文章

  1. UITableView中cell里的UITextField不被弹出键盘挡住

    UITableView中cell里的UITextField不被弹出键盘挡住 本人视频教程系类   iOS中CALayer的使用 效果如下: 源码: EditCell.h 与 EditCell.m // ...

  2. 用适配器模式处理复杂的UITableView中cell的业务逻辑

    用适配器模式处理复杂的UITableView中cell的业务逻辑 适配器是用来隔离数据源对cell布局影响而使用的,cell只接受适配器的数据,而不会与外部数据源进行交互. 源码: ModelCell ...

  3. UITableView中cell点击的绚丽动画效果

    UITableView中cell点击的绚丽动画效果 本人视频教程系类   iOS中CALayer的使用 效果图: 源码: YouXianMingCell.h 与 YouXianMingCell.m / ...

  4. 使用JS,获取URL中指定参数的值

    /** * 获取URL中指定参数的值 * * @param name 参数名称 * @returns */ function getQueryString(name) { var reg = new ...

  5. Flex中获取RadioButtonGroup中的RadioButton的值

    Flex中获取RadioButtonGroup中的RadioButton的值 1.设计源码 <?xml version="1.0" encoding="utf-8& ...

  6. 关于使用uitableview 中cell 来实现uiimageview的复用和图片的异步加载

    apple sample lazytableimages 1,首先设置横向显示的uitableview self.customTableview.transform = CGAffineTransfo ...

  7. iOS - UITableView中Cell重用机制导致Cell内容出错的解决办法

    "UITableView" iOS开发中重量级的控件之一;在日常开发中我们大多数会选择自定Cell来满足自己开发中的需求, 但是有些时候Cell也是可以不自定义的(比如某一个简单的 ...

  8. 解决UITableView中Cell重用机制导致内容出错的方法总结

    UITableView继承自UIScrollview,是苹果为我们封装好的一个基于scroll的控件.上面主要是一个个的 UITableViewCell,可以让UITableViewCell响应一些点 ...

  9. C# 获取listview中选中一行的值

    首先必须要判断listView1.SelectedItems.Count>0或是listview1.SelectedIndices.Count>0,否则第一次点击会选不中.其次,好像ite ...

随机推荐

  1. windows下安装并使用redis

    一.安装前首先了解一下phpinfo里面的一些信息,能否正确安装非常有帮助. (下图是我的本机环境) compiler :编译器 Architecture :CPU架构 Configuration F ...

  2. ELK日志系统之使用Rsyslog快速方便的收集Nginx日志

    常规的日志收集方案中Client端都需要额外安装一个Agent来收集日志,例如logstash.filebeat等,额外的程序也就意味着环境的复杂,资源的占用,有没有一种方式是不需要额外安装程序就能实 ...

  3. Spring Boot 使用Redis

    转载自:http://www.cnblogs.com/ityouknow/p/5748830.html Redis支持更丰富的数据结构,例如hashes, lists, sets等,同时支持数据持久化 ...

  4. java.lang.NoSuchMethodError: org.json.JSONArray.iterator()Ljava/util/Iterator 阿里云短信

    请尝试使用 <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk ...

  5. 理解Spring定时任务的fixedRate和fixedDelay

    用过  Spring 的 @EnableScheduling 的都知道,我们用三种形式来部署计划任务,即 @Scheduled 注解的 fixedRate(fixedRateString), fixe ...

  6. bet阶段验收互评

    小组名字和链接 优点 缺点,bug报告 最终名次 Gakki赛高[二十四点小游戏] 1.界面与上阶段相比更好了2.新增闯关设计,提升游戏性3.功能完善 1.下载方式不方便2.排行榜设计较为简陋 1 编 ...

  7. solr 6.6 基础环境搭建 (一)

    Apache Solr 介绍 参考博主原文链接1:http://www.cnblogs.com/blueskyli/p/7100443.html 参考博主原文链接2:http://www.cnblog ...

  8. C# byte 和 char 转化

    C#  byte 和 char 可以认为是等价的.但是在文本显示的时候有差异.   c# 使用的是unicode字符集,应该和为ascii相互转换 只能转换到字符的unicode编码,或者由unico ...

  9. 鼠标样式——css国际组织

    w3c国际标准组织提供的鼠标样式: http://css-cursor.techstream.org/

  10. Android基础知识你知道多少?

    https://github.com/zhantong/interview/blob/master/Android/Android.md 四大组件是什么? 四大组件的启动方式? Activity生命周 ...