一、添加UITableViewCell为自己设计的风格

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

//两个section cell id要不同

if(indexPath.section == 0)

{

NSString *CellIdentifier = [NSString stringWithFormat:@"cell%d",indexPath.row];

NSLog(@"willAnimateRotationToInterfaceOrientation === TQDownViewCell");

TQDownViewCell *cell = (TQDownViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)

{

cell = [[[TQDownViewCell alloc] initWithFrame:CGRectMake(0, 0, m_downView.frame.size.width, TQDOWNCELL_HEIGHT) reuseIdentifier:CellIdentifier] autorelease];

}

cell.selectionStyle = UITableViewCellSelectionStyleNone;

TQDownItem *item = [[TQDownList shareInstance] taskAtIndex:indexPath.row];

cell.downItem = item;

return cell;

}else if(indexPath.section == 1)

{

NSString *CellIdentifier = [NSString stringWithFormat:@"cell_2%d",indexPath.row];

NSLog(@"willAnimateRotationToInterfaceOrientation === TQDownViewBackInfoCell");

TQDownViewBackInfoCell *backCell = (TQDownViewBackInfoCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (backCell == nil)

{

backCell = [[[TQDownViewBackInfoCell alloc] initWithFrame:CGRectMake(0, 0, m_downView.frame.size.width, TQDOWNCELL_HEIGHT) reuseIdentifier:CellIdentifier] autorelease];

}

backCell.selectionStyle = UITableViewCellSelectionStyleNone;

TQVideoDownItem *item = [[TQDownList shareInstance] getCurrentBackgroupDownInfo];

if(item)

{

m_currenBackInfoNum = 1;

backCell.downItem = item;

}else

{

m_currenBackInfoNum = 0;

backCell.downItem = nil;

}

return backCell;

}

return nil;

}

二。修改UITableView的footer 和 head

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

{

if (section == 0) {

CGRect screenRect = [[UIScreen mainScreen] applicationFrame];

UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, 310, screenRect.size.height)];

footerView.autoresizesSubviews = YES;

footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

footerView.userInteractionEnabled = YES;

footerView.hidden = NO;

footerView.multipleTouchEnabled = NO;

footerView.opaque  = NO;

footerView.contentMode = UIViewContentModeScaleToFill;

UILabel* footerLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 9, 300, 60.0)];

footerLabel.backgroundColor = [UIColor clearColor];

footerLabel.opaque = NO;

footerLabel.text = _(@"RSS Description");

footerLabel.textColor = [UIColor lightGrayColor];

footerLabel.font = [UIFont systemFontOfSize:17];

footerLabel.numberOfLines = 10;

[footerView addSubview:footerLabel];

[footerLabel release];

//return _(@"RSS Description");

return footerView;

}

return nil;

}

三、允许对cell进行编辑(删除、拖动等)

-(BOOL)tableView:(UITableView *) tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

{

//打开编辑

return YES;

}

- (void)setEditing:(BOOL)e animated:(BOOL)ani

{

[super setEditing:e animated:ani];

[mSpecialTableView setEditing:e animated:ani];//tableView 设置

if (e) self.editButtonItem.title = _(@"done");

else self.editButtonItem.title = _(@"edit");

}

//tableView 中cell选中事件

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

NSInteger specialIndex = [[TQDownList shareInstance] getCurSepcailIndex:indexPath.row];

NSString *strKey = [[TQDownList shareInstance] getCurRowIndex:specialIndex];

TQDownViewSecondPage *taskPage = [[TQDownViewSecondPage alloc] init];

[taskPage setSpecialKey:strKey];

[self.navigationController pushViewController:taskPage animated:YES];

[taskPage release];

}

//编辑tableView 时调整cell view里的控件位置

- (void)layoutSubviews

{

#define REDUCE_LEN 59

int tag = 25;

if (self.editing)

{

//编辑时的位置

} else

{

//默认位置

}

[super layoutSubviews];

}

四、允许cell之间的拖动

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath

{

//允许移动

return YES;

//return NO;

}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath

{

//交换数据

}

类别:默认分类 查看评论

转载于:https://www.cnblogs.com/anmog/archive/2011/03/08/1978624.html

UITableView 关键操作相关推荐

  1. 服务器的操作审计信息,裸金属服务器关键操作审计

    裸金属服务器关键操作审计 内容精选 换一换 为了方便用户在管理控制台上进行裸金属服务器实例管理,可快速辨别出每台服务器的名字,华为云支持给每台服务器命名,并且可以随时更改,重启生效.Windows裸金 ...

  2. 做系统的关键操作的日志功能

    问题: 项目系统需要记录用户的关键操作日志,以便后期的系统维护,方便的查看问题,及时排除等原因. 分析: 作为一个日志记录功能,首先数据库新建一张表保存用户的操作关键字段,用户名,ip,操作描述,时间 ...

  3. 美赛LaTeX关键操作讲解--绘制表格,插入图片、公式、代码块

    后天2022年美赛就开始了,针对写作要求,博主着重整理了一下运用LaTeX绘制表格,插入图片.公式的详细操作以及相应的注释要求.(以下代码直接复制便可以使用,编号格式方面以及设置好了) 希望大家都能在 ...

  4. Fragment之底层关键操作函数moveToState

    moveToState是FM中一个相当长的函数,但Fragment任何的操作add,remove -最终都会调用这个函数,从字面上可以理解,fragment要从当前状态切到newState里面干些什么 ...

  5. jqgrid 列表条件查询的几步关键操作

    jqgrid列表条件查询 记录一下我自己老忘的几个点 这次记录一下使用jqgrid在列表查询时的关键点,过一段时间不用就是忘 1]在html页面用 v-model="q.xxx" ...

  6. PCB布局和绘制的关键操作

    1.模块由原理图转为PCB时的局部整理 原理图局部框出⇨PCB中工具⇨器件摆放⇨在矩形区域内放置 最终如图所示: 2.黄色字体调节 选中字体右击鼠标⇨查找相似对象⇨layer中Any改成same⇨在右 ...

  7. 编译 Apache Spark 源码报错?那是因为你漏掉了关键操作

    前言 本文隶属于专栏<1000个问题搞定大数据技术体系>,该专栏为笔者原创,引用请注明来源,不足和错误之处请在评论区帮忙指出,谢谢! 本专栏目录结构和参考文献请见1000个问题搞定大数据技 ...

  8. DELL R730 从U盘启动 从U盘启动盘安装系统的关键操作

    1,关键是设置UEFI模式: System Bois Settings , Boot Settings, Boot Mode设置成 UEFI模式 2,设置从U盘启动 3,重启的时候手动选择从USB启动

  9. EOS 智能合约源代码解读 (10)token合约“几种关键操作”

    1. create:负责创建资产 void token::create( const text_name& issuer, const asset& maximum_supply) { ...

最新文章

  1. 什么是javadoc文档
  2. C# 模拟 Post
  3. Google的价值观
  4. 操作系统学习(五) 、代码段和数据段描述符
  5. Linux 安装卸载软件及管理软件仓库
  6. LeetCode MySQL 1747. 应该被禁止的Leetflex账户
  7. 猜物品游戏java编程_小猿圈Java初学者练习小案例:猜数字游戏
  8. mysql first value_开窗函数 First_Value 和 Last_Value
  9. WEB流程设计器 = jQuery + jsPlumb + Bootstrap
  10. google翻译自动检测语言翻译成中文
  11. mysql8.0怎么设置中文版_MySQL 8.0 版本修改字符编码
  12. Word2010图片组合
  13. 浪潮信息m6服务器性能,展现强劲性能,浪潮M6服务器为什么能刷新SPEC多项记录...
  14. Docker基础30--6.4 Docker三剑客之Swarm
  15. PHP 微信JSP支付
  16. 总结工作中nginx、git、linux、ES、lamada表达式、sql
  17. 两万字:讲述微信小程序之组件
  18. 网络 启动计算机,电脑进入bios怎么设置网卡启动
  19. java rtp 分片_RTP 协议解包为 H264 裸流
  20. sqlserver中的表值函数和标量值函数

热门文章

  1. js 禁止复制粘贴全选
  2. 全局变量:global与$GLOBALS的区别和使用
  3. 使用NTDSXtract离线抓取Domain Hash
  4. 关于JVM结构的学习
  5. Android 修改Progressbar 旋转速度
  6. Android getLocationInWindow
  7. android stadio mapping文件的使用
  8. git 提交的时候报错:error: 'flutter_app/' does not have a commit checked out
  9. 学习JNI一些基础知识
  10. 微型计算机存取速度,微型计算机中,存取速度由快到慢排序: