第一条: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. Kubernetes日志收集

    关于kubernetes的日志分好几种,针对kubernetes本身而言有三种: 1.资源运行时的event事件.比如在k8s集群中创建pod之后,可以通过 kubectl describe pod ...

  2. 手机自动化测试:appium源码分析之bootstrap四

    手机自动化测试:appium源码分析之bootstrap四   Orientation是调整屏幕方向的操作 package io.appium.android.bootstrap.handler; i ...

  3. MySQL学习笔记(三)—索引

    一.概述 1.基本概念       在大型数据库中,一张表中要容纳几万.几十万,甚至几百万的的数据,而当这些表与其他表连接后,所得到的新的数据数目更是要大大超出原来的表.当用户检索这么大量的数据时,经 ...

  4. mysql 分析2 show processlist ;

    show processlist ; 可以查看当前有哪些链接 处于什么状态 分析语句 那些连接处于什么状态 (需要通过脚本观察一段时间内的有运行情况做出统计一直刷新服务器运行状态 ) 当出现下面的几种 ...

  5. Git版本管理荟萃

    用惯了svn,突然转到git难免有点不适,写个笔记好好备忘总结一番. 一.先看历史(imooc上的一个图): 二.git与svn GIT跟SVN一样有自己的集中式版本库或服务器.但,GIT更倾向于被使 ...

  6. cloud-init 典型应用 - 每天5分钟玩转 OpenStack(174)

    本节介绍几个 cloud-init 的典型应用:设置 hostanme,设置用户初始密码,安装软件. 设置 hostname cloud-init 默认会将 instance 的名字设置为 hostn ...

  7. 循环神经网络RNN公式推导走读

    0语言模型-N-Gram 语言模型就是给定句子前面部分,预测后面缺失部分 eg.我昨天上学迟到了,老师批评了____. N-Gram模型: ,对一句话切词 我 昨天 上学 迟到 了 ,老师 批评 了 ...

  8. 关于php 高并发解决的一点思路

    涉及抢购.秒杀.抽奖.抢票等活动时,为了避免超卖,那么库存数量是有限的,但是如果同时下单人数超过了库存数量,就会导致商品超卖问题.那么我们怎么来解决这个问题呢,我的思路如下(伪代码): sql1:查询 ...

  9. Java关于Robot类的使用以及远程桌面的实现

    利用Robot实现效果是运行之后鼠标自动定位到整个屏幕坐标系的(635,454)位置,输入wangtianze package com.wtz.util; import java.awt.AWTExc ...

  10. 【shell编程基础2】shell组合应用之一:重定向和逻辑

    这篇主要讲下 数据的重定向,在shell脚本中有些重要的输出重定向为文件的形式输出来 逻辑方式的多个命令组合,可以很方便的进行一些判断 数据流重定向 数据流重定向:大致上的意思就是本该输出到屏幕上的数 ...