ios TableView那些事(三十 五)TableView 单选操作使用Autolayout实现UITableView的Cell动态布局和高度动态改变
来源:互联网 发布:支付宝软件 编辑:程序博客网 时间:2024/05/21 10:40
详解点击 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
iOS8的示例代码
iOS7的示例代码
实战demo下载
实例代码
// ViewController.m
// SiziingDemo
//
// Created by lengshengren on 16/3/17.
// Copyright © 2016年 Rnning. All rights reserved.
//
import “ViewController.h”
import “CustomTableViewCell.h”
@interface ViewController ()
@property (strong, nonatomic)NSArray *countArray;
@end
@implementation ViewController
(void)viewDidLoad {
[super viewDidLoad];self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 100.0;self.countArray = @[@”今天真高兴”,@”传闻已久的2016苹果春季发布会时间终于尘埃落定,日前苹果在官网上发出邀请函,宣布将于美国东部时间3月21日下午1点(北京时间3月22日凌晨1点)举行发布会,地点设在苹果公司的加州库比蒂诺总部,邀请函的标题文案是“Let us loop you in”,@”【“阿尔法狗”真的让人担心吗?】围棋是人工智能领域的一个具有标志性的挑战,现在“阿尔法狗”战胜了世界冠军李世石,是否意味着霍金对人工智能的担忧将成为现实?人工智能对人类生存的威胁会超过核武器吗?对于这一重大问题,一些人工智能的支持者却不这么认为”,@”哈哈”];
// Do any additional setup after loading the view, typically from a nib.
}(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentSizeCategoryChanged:)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
}(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIContentSizeCategoryDidChangeNotification
object:nil];
}(void)contentSizeCategoryChanged:(NSNotification *)notification
{
[self.tableView reloadData];
}(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
pragma mark - UITableViewDataSource
(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return 4;
}(UITableViewCell )tableView:(UITableView )tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@”cell” forIndexPath:indexPath];
[self configureCell:cell forRowAtIndexPath:indexPath];[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];
return cell;
}(void)configureCell:(CustomTableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.countenLable.text = self.countArray[indexPath.row];
}
- ios TableView那些事(三十 五)TableView 单选操作使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- ios TableView那些事(三十 五)TableView 单选操作使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- IOS 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- iOS 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度的动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- [译]使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- C++虚继承(四) --- /d1 reportSingleClassLayout插入看类内存布局
- Qt Creater 制作汽车仪表盘
- Linux errno参照表
- 每天进步一点点——五分钟理解一致性哈希算法(consistent hashing)
- android中实现view的更新有两组方法
- ios TableView那些事(三十 五)TableView 单选操作使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- C++创建使用静态动态库
- Java 架构师是怎样练成的
- 工厂模式
- 使用spring boot快速构建spring框架的maven项目
- 结构体在内存中的对齐规则
- 2016年一级建造师考试报名指南
- 解决python "Non-ASCII character"错误
- CMakeup