第一条:UITableViewCell 内容的设置
//文本放到最后
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_dataArr.count - 1 inSection:0];
[_tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
 
//刷新指定cell
NSIndexPath *indexPath_3=[NSIndexPath indexPathForRow:0 inSection:2];
NSArray *indexArray3=[NSArray arrayWithObject:indexPath_3];
[self.tableview reloadRowsAtIndexPaths:indexArray3 withRowAnimation:UITableViewRowAnimationAutomatic];
 
 
第二条:UITableViewCell分割线左边部分缺少一些的解决方法
-(void)viewDidLayoutSubviews {
  if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [self.tableView setSeparatorInset:UIEdgeInsetsZero];
  }
  if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])  {
    [self.tableView setLayoutMargins:UIEdgeInsetsZero];
  }
}
 
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
   
  if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    [cell setLayoutMargins:UIEdgeInsetsZero];
  }
  if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
    [cell setSeparatorInset:UIEdgeInsetsZero];
  }
}
 
第三条:UITableView的分割线部分不显示的问题?
simulator -> debug -> optimize rendering for window scale 取消打勾就好
 
 
第四条: 自定义cell分割线大致用到的两种方法
 
   a、把自定义的分割线当成一个View放到cell的contentView上,一定要注意重用问题,所以这个view 要在cell初始化的时候添加上。示例代码如下:
 

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #6122ae }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3e1e81 }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; min-height: 21.0px }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1e9421 }
span.s1 { }
span.s2 { color: #6122ae }
span.s3 { color: #000000 }
span.s4 { color: #c42275 }
span.s5 { color: #c81b13 }
span.s6 { color: #703daa }
span.s7 { color: #3e1e81 }
span.s8 { color: #0435ff }

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

   UITableViewCell *cell =nil;

  cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

   if (cell ==nil) {

   cell= [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];

    cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"huicellacce"]];  

  cell.backgroundColor = [UIColor clearColor];

          //cell.selected = YES;

       UIImageView *imageViewSepE = [[UIImageView alloc]initWithFrame:CGRectMake(47, 49, 200, 1)];

    imageViewSepE.image  = [UIImage imageNamed:@"godline"];

          [cell.contentView addSubview:imageViewSepE];

   }

   return cell;

  }

 
  b、比较复杂,用到了底层的框架

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3e1e81 }
span.s1 { }
span.s2 { color: #c42275 }
span.s3 { color: #703daa }
span.s4 { color: #000000 }
span.s5 { color: #6122ae }
span.s6 { color: #3e1e81 }
span.s7 { color: #0435ff }
span.s8 { color: #1e9421 }
span.s9 { font: 18.0px "PingFang SC"; color: #1e9421 }

  - (void)drawRect:(CGRect)rect {

   CGContextRef context = UIGraphicsGetCurrentContext();

   CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor); CGContextFillRect(context, rect);

   CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);

   CGContextStrokeRect(context, CGRectMake(5, -1, rect.size.width - 10, 1)); //下分割线

   CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);

   CGContextStrokeRect(context, CGRectMake(5, rect.size.height, rect.size.width - 10,1));

  }

 
 
第五条: 用代码的方式自定制cell,必须写initWithStyle的方法
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier{
   
  self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
     if (self) {          
    /*** 这里写要添加控件   ***/
     }   
  return self;
}
 
 
 【iOS开发TableView】TabelView自定义cell
 
第一种:通过创建xib文件。
 
①首先创建xib文件
 
②创建xib文件对应 的模型A,名字与xib文件一样,并继承UITableViewCell类,并实现cellWithTableView的构造方法。
 
③在interface builder里更改xib文件默认的类,为第二步创建的模型类。
 
④创建数据模型B,并且A中包含数据模型B
 
⑤A通过懒加载B方法(就是重写B对象的setter方法)将控件赋值。
 
 
 
第二种:代码自定义cell
 
①新建一个继承UITableViewCell的类,里面拥有frame模型
 
②重写initWithStyle:reuseIdentifier:方法(添加所有需要显示的子控件(不需要设置子控件的数据和frame,  子控件要添加到contentView中,还有添加属性设置).
 
③建立数据模型
 
④建立frame模型(拥有数据模型)
 
⑤重写数据模型对象的setter方法,然后再里面设置控件大小,和cell的高度。
 
⑥控制器拥有frame对象数组。出事Cell的时候直接赋值给cell.frame对象就行。
 
 
第六条:iOS开发 - 让tableView不能下拉刷新,可以上拉加载
1. 首先遵循代理  UIScrollViewDelegate
2.实现代理方法即可
-(void)scrollViewDidScroll:(UIScrollView
*)scrollView{
    if (tabelView.contentOffset.y <= 0) {
        tabelView.bounces = NO;
    }else {
        tabelView.bounces = YES;
    }
}
 
第七条:去除UITableView底部多余行及分割线
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
 

iOS开发,UITableView相关问题的更多相关文章

  1. iOS 开发,相关网址

    iOS 开发,相关网址 说明 网址 注册开发者 https://developer.apple.com/cn/programs/enroll/ 未付费688个人开发账号真机调试测试教程 http:// ...

  2. iOS开发UITableView基本使用方法总结

    本文为大家呈现了iOS开发中UITableView基本使用方法总结.首先,Controller需要实现两个delegate ,分别是UITableViewDelegate 和UITableViewDa ...

  3. iOS开发UITableView基本使用方法总结 分类: ios技术 2015-04-03 17:51 68人阅读 评论(0) 收藏

    本文为大家呈现了iOS开发中UITableView基本使用方法总结.首先,Controller需要实现两个delegate ,分别是UITableViewDelegate 和UITableViewDa ...

  4. iOS:UITableView相关(18-10-20更)

    UITableView用得较多,遇到的情况也较多,单独记录一篇. 一.零散的技巧 二.取cell 三.cell高度 四.导航栏.TableView常见问题相关 五.自定义左滑删除按钮图片 六.仅做了解 ...

  5. iOS开发其他相关

    1.iOS开发行情 1.1 iOS系统各个版本的占比查询 2.Xcode的使用 开发软件下载 Xcode Help(官方) 2.1 Xcode面板 Xcode面板 2.2 Xcode版本新功能 Xco ...

  6. iOS开发传感器相关

    手机里面内置了很多的传感器,例如:光传感器,湿度传感器,温度传感器,距离传感器等等 //开发传感器相关的东西必须使用真机 //在螺旋仪和加速计所有两种方式push和pull的方式,push的方式是时时 ...

  7. iOS开发-UITableView自定义Cell

    UITableView在iOS中开发的重要地位是毋庸置疑的,基本上应用中用到的比例是一半左右,而且大部分情况都是需要自定义单元格的,这样用户看到的App才能更有美感.之前写过UITableView的基 ...

  8. iOS开发 UITableView之cell

    1.cell简介 UITableView的每一行都是一个UITableViewCell,通过dataSource的tableView:cellForRowAtIndexPath:方法来初始化每一行 U ...

  9. iOS开发-UITableView表格优化

    之前的一篇文章大概讲述了一下UITableView的使用,UITableView在iOS的地位和ListView在Android中的地位基本上算是不相上下,关于ListView的优化网上的也有很多文章 ...

随机推荐

  1. C++ 虚函数相关,从头到尾捋一遍

    众所周知,C++虚函数是一大难点,也是面试过程中必考部分.此次,从虚函数的相关概念.虚函数表.纯虚函数.再到虚继承等等跟虚函数相关部分,做一个比较细致的整理和复习. 虚函数 OOP的核心思想是多态性( ...

  2. 老李推荐:第14章5节《MonkeyRunner源码剖析》 HierarchyViewer实现原理-装备ViewServer-查询ViewServer运行状态

    老李推荐:第14章5节<MonkeyRunner源码剖析> HierarchyViewer实现原理-装备ViewServer-查询ViewServer运行状态   poptest是国内唯一 ...

  3. 老李性能测试分享:可以没事代理刷榜赚外快了,poptest这是让你快速致富啊

    老李性能测试分享:可以没事代理刷榜赚外快了,poptest这是让你快速致富啊   最近学员不断面试,不时听到令人惊喜的消息,类似应届专科毕业生获得7k月薪,小美女应聘月薪11k等等,看到学员开心的笑容 ...

  4. ecshop SQL注入漏洞导致代码执行

    漏洞名称:ecshop SQL注入漏洞导致代码执行补丁编号:11208761补丁文件:/includes/libinsert.php补丁来源:云盾自研漏洞描述:ecshop的/includes/lib ...

  5. 上传图片转为base64格式预览并压缩图片(不兼容IE9以下浏览器,兼容移动端ios,android)

    前些天公司要求在微信移动端做上传图片并预览的功能,要求能够调用摄像头拍照并立即预览. 在网上搜了一些方法,开始自己写了个简单的功能实现代码.结果发现移动端拍照出来的图片动不动就2M+,又因为要批量上传 ...

  6. 【算法功底】LeetCode 292 Nim Game

    You are playing the following Nim Game with your friend: There is a heap of stones on the table, eac ...

  7. Sphinx安装流程及配合PHP使用经验

    1.什么是Sphinx Sphinx是俄罗斯人Andrew Aksyonoff开发的高性能全文搜索软件包,在GPL与商业协议双许可协议下发行. 全文检索式指以文档的全部文本信息作为检索对象的一种信息检 ...

  8. Spring+SpringMVC+MyBatis+easyUI整合优化篇(六)easyUI与富文本编辑器UEditor整合

    日常啰嗦 本来这一篇和接下来的几篇是打算讲一下JDBC和数据库优化的,但是最近很多朋友加我好友也讨论了一些问题,我发现大家似乎都是拿这个项目作为练手项目,作为脚手架来用的,因此呢,改变了一下思路,JD ...

  9. 跟着刚哥梳理java知识点——HelloWorld和常见问题(一)

    1.按照国际惯例,写一段输出HelloWorld的java语句: public class HelloWorld { //这是main方法,程序的主入口 public static void main ...

  10. javaScript 基本类型之间转换

    在Java中,基本类型之间的强制转换也不是这样的,比如,整数要转换成字符串,必须使用Integer.toString()静态方法或者String.valueOf()静态方法,把字符串转换为整数,必须使 ...