IOS table动态cell - 笔记
来源:互联网 发布:韩国烤肉知乎 编辑:程序博客网 时间:2024/06/02 01:14
//// LPViewController.m// temp//// Created by linpeng on 14-6-13.// Copyright (c) 2014年 linpeng. All rights reserved.//#import "LPViewController.h"@interface LPViewController ()<UITableViewDataSource,UITableViewDelegate>{ UITableView *_table; NSMutableArray *_dataList; UIView *footView;}@end@implementation LPViewController- (void)viewDidLoad{ [super viewDidLoad]; _table=[[UITableView alloc]initWithFrame:CGRectMake(0, 60, self.view.frame.size.width, self.view.frame.size.height)]; _table.delegate=self; _table.dataSource=self; //_table.multipleTouchEnabled=YES; [self.view addSubview:_table]; _dataList=[[NSMutableArray alloc]initWithObjects:@"1111\n111\n111\n111\n",@"22gdhajs大神进口到哈市好久打卡收款单号卡就是的空间安徽省科技等哈可节省空间和思考接电话开机和登记卡斯柯达灰色空间和空间撒的空间数据库等会教科书的教科书科技等哈收到空间撒接口等哈的空间阿红的空间安徽省科技等哈上课的话2",@"333",@"444",@"555",@"666",@"777", nil]; footView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 80)]; footView.backgroundColor=[UIColor yellowColor]; _table.tableFooterView=footView;}#pragma mark - UITableView-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1;}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [_dataList count];}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ; UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; label.tag = 1; //label.lineBreakMode = UILineBreakModeCharacterWrap; label.lineBreakMode=NSLineBreakByCharWrapping; label.highlightedTextColor = [UIColor whiteColor]; label.numberOfLines = 0; label.opaque = NO; // 选中Opaque表示视图后面的任何内容都不应该绘制 label.backgroundColor = [UIColor clearColor]; [cell.contentView addSubview:label]; } UILabel *label = (UILabel *)[cell viewWithTag:1]; NSString *text; text = [_dataList objectAtIndex:indexPath.row]; CGRect cellFrame = [cell frame]; cellFrame.origin = CGPointMake(0, 0); label.text = text; CGRect rect = CGRectInset(cellFrame, 2, 2); label.frame = rect; [label sizeToFit]; if (label.frame.size.height > 46) { cellFrame.size.height = label.frame.size.height+4; } else { cellFrame.size.height = 50; label.frame = CGRectMake(label.frame.origin.x, (50-label.frame.size.height)/2, label.frame.size.width, label.frame.size.height); } [cell setFrame:cellFrame]; return cell;}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath]; return cell.frame.size.height;}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- IOS table动态cell - 笔记
- ios学习--table cell定制
- iOS开发笔记-cell里点击按钮展开收起-动态改变cell行高
- IOS动态获取cell高度
- (iOS开发) 动态cell高度
- ios中自定义table view cell
- iOS开发笔记- cell里放textView根据输入的文字动态改变textView以及cell高度
- 【代码笔记】iOS-cell折叠
- ios开发笔记之如何让tableView根据文本内容动态改变cell的高度
- iOS cell高度自适应_动态调节cell高度
- display table table-cell
- IOS 动态改变cell的高度
- IOS 动态改变cell的高度
- IOS 之动态调整cell高
- ios实现动态加载cell高度
- iOS开发动态计算cell的高度
- iOS开发动态计算cell的高度
- iOS开发动态计算cell的高度
- 怎么恢复移动硬盘丢失的文件呢
- 对ddl的改变自动触发事件
- 现代汉语词语切分研究
- CXF 简易搭建说明与实例下载
- cocos2d-x 3.0 final 九宫图的特别使用技巧
- IOS table动态cell - 笔记
- Spring 的组件自动扫描机制
- iframe子父页面调用
- T_T继续第四章
- Web服务器管理系列:2、激活操作系统
- ejabberd 安装记录
- [设计] - 概说概要设计怎么做 - 结构化设计方法与面向对象设计方法
- 电脑剪切的文件不显示如何恢复
- 页面传值后绑定ddl