UITableView 点击展开的实现
2015-10-16 11:06
441 查看
推介看下这里的 内容 http://www.cnblogs.com/kenshincui/p/3931948.html
IOS8 above
UITabliViewCell 利用 autolayout 实现的,这里就不多说了
主要代码
1.
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 70;
2.
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"heightForRowAtIndexPath=:%ld",indexPath.row);
if( indexPath.row == selectIndex )
{
if( !isOpened )
return 130;
return UITableViewAutomaticDimension;
}
else
{
return 130;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
selectIndex = indexPath.row;
isOpened = !isOpened;
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
IOS8 above
UITabliViewCell 利用 autolayout 实现的,这里就不多说了
主要代码
1.
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 70;
2.
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"heightForRowAtIndexPath=:%ld",indexPath.row);
if( indexPath.row == selectIndex )
{
if( !isOpened )
return 130;
return UITableViewAutomaticDimension;
}
else
{
return 130;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
selectIndex = indexPath.row;
isOpened = !isOpened;
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
相关文章推荐
- I/O exception (java.net.SocketException) caught when processing request: Connect
- UIScrollViewDelegate
- 读《认知与设计:理解UI设计准则》第一章
- Android回调机制简单总结:Handler更新UI
- saltstack UI界面安装
- 源码推荐(10.09):UITableViewCell自适应大小,3D Touch 简单demo
- 自定义UIPageControl小点的颜色
- 实时显示iOS编写UI代码效果
- default parameter value for ‘color’ must be a compile-time constant
- Cocoa深入学习:NSOperationQueue、NSRunLoop和线程安全
- 第一天开通,记录下ueditor的大小设置
- 关于UITabar的一些自定义方法
- Android第三方模拟器使用:bluestracks和Genymotion
- UIWindow UIScreen UIViewController UIView之间的关系
- iOS 笔记八:Core Animation、Dynamic Animation、 UIDynamicBehavoir
- IOS学习动画一之 UIKit动画
- iOS UIView 添加点击事件
- UIDatePick,UIPick
- requireJS参数传递
- UIImage 和 NSString 之间的互转