二者差不多,拿数据源说吧,n个section,每个section里面cell个数不固定,数据源内容不一定,导致cell形式会不一样

从数据源中取如果写if else,或者switch都不满意,也许Swift更牛一些,这里不提

说白了就是想根据所具有资源计算出不同cell对应的唯一的数据源数组的索引值

写的不好,如果有更好的希望分享一下,互相学习!(几十个scetion应该没有明显的效率诧异)

不多说上代码:

-(NSArray *)arrayTitle

{

if (!_arrayTitle) {

_arrayTitle = @[@"不让他(她)看我的家谱",@"不让他(她)看我的动态",@"不看他(她)的动态"];

}

return @[@"不让他(她)看我的家谱",@"不让他(她)看我的动态",@"不看他(她)的动态"];

}

-(NSArray *)arrayVCForJump

{

if (!_arrayVCForJump) {

_arrayVCForJump = @[[MHNotShowFamilyTreeController class],[MHNotShowEventToOtherController class],[MHNotSeeOtherEventController class]];

}

return _arrayVCForJump = @[[MHNotShowFamilyTreeController class],[MHNotShowEventToOtherController class],[MHNotSeeOtherEventController class]];

}

#pragma mark计算出当前数组的索引值,根据indexPath保证不会因为section多而重复

-(NSInteger)getCurrentIndexForDataArray:(NSIndexPath*)indexPath tableView:(UITableView *)tableView

{

//****************

self.numOfIndexPromate =0;

for (NSInteger i=0; i<indexPath.section; i++) {

self.numOfIndexPromate += [tableView numberOfRowsInSection:i];

}

//***************

return self.numOfIndexPromate;

}

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

{

//cell很少暂时可不考虑重用

MHPrivacyTableViewCell * cell = [[MHPrivacyTableViewCell alloc]init];

cell.textLabel.textColor = MHEventCellTitleColor;

//    cell.textLabel.text = self.arrayTitle[indexPath.row+indexPath.section];//此处取值在多个section不唯一,以后要注意

NSInteger num = [self getCurrentIndexForDataArray:indexPath tableView:tableView];

cell.textLabel.text = self.arrayTitle[num+indexPath.row];

return cell;

}

#pragma mark - 点击cell跳转代理

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

{

NSInteger num = [self getCurrentIndexForDataArray:indexPath tableView:tableView];

Class strVcName = self.arrayVCForJump[indexPath.row+num];

//    Class strVcName = self.arrayVCForJump[indexPath.row+indexPath.section];

NSString * strClassName = NSStringFromClass(strVcName);

if ([strClassName isContainOneStr:@"Controller"]) {

UIViewController * vc = [[strVcName alloc]init];

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

}

else

{

return;

}

}

转载于:https://www.cnblogs.com/daaiwusehng/p/4975442.html

tableView的懒懒的跳转方式,加载数据源方式相关推荐

  1. 《ArcGIS Runtime SDK for Android开发笔记》——(13)、图层扩展方式加载Google地图...

    1.前言 http://mt2.google.cn/vt/lyrs=m@225000000&hl=zh-CN&gl=cn&x=420&y=193&z=9& ...

  2. 使用jQuery和YQL,以Ajax方式加载外部内容

    我们来看看怎样使用jQuery,以Ajax方式加载外部(其他域上)的内容.这里的所有代码都可以从GitHub下载,也可以在这个演示页面中获取,因而不用复制粘贴了. OK,Ajax通过jQuery是很容 ...

  3. Unity—AssetBundle的打包及四种加载资源方式

    AssetBundle打包:脚本放在Editor文件夹内 具体代码如下: using UnityEditor; using System.IO;public class CreateAssetBund ...

  4. 使用SDWebImage淡入淡出的方式加载图片

    使用SDWebImage淡入淡出的方式加载图片 效果: 请通过以下方式下载源码: 找到它修改文件的地方: 以下是使用源码: // // ViewController.m // SDWebImageFa ...

  5. pythonflask configlist.py_Python+Flask.0004.FLASK配置管理之三种方式加载外部配置

    简单介绍: 说明: 复杂的项目需要配置各种环境,若设置少可直接硬编码,设置多的话可通过加载配置/加载文件/加载变量的方式来设置 1 2 3 app.config.update( DEBUG=True, ...

  6. java spring包_java 自定义加载器,加载spring包,动态加载实现,jar包隔离,tomcat加载webapp方式...

    java 自定义加载器,加载spring包,动态加载实现,jar包隔离,tomcat加载webapp方式 发布时间:2018-08-20 12:02, 浏览次数:774 , 标签: java spri ...

  7. 【js】【cornerstone】cornerstone使用url方式加载图像

    [js][cornerstone]cornerstone使用url方式加载图像 引入cornerstoneWebImageLoader loadImage 引入cornerstoneWebImageL ...

  8. post方式加载iframe

    我们平常使用iframe时,直接设定src属性只能是get请求方式 ,get请求的参数大小有限制 如何实现即使用iframe又能通过post请求 两种方式 ajax使用post请求返回页面,直接将返回 ...

  9. Unity两中方式加载图片

    看到草羊发的图片,也是真懒. 想起来当时写天气预报现在都忘干净了,好记性不如烂笔头,还是应该多记.自己打下来好了 using System; using System.Collections; usi ...

最新文章

  1. linux平台调试终端,10款Linux平台上优秀的调试器,总有一款适合你!
  2. 图解使用Win8Api进行Metro风格的程序开发十一----联系人选择
  3. android 炫酷背景,炫酷-背景图垂直循环滚动登录页,Android RecyclerView实现
  4. SpringBoot框架与MyBatis集成,连接Mysql数据库
  5. [转载]ASP.NET Core文件上传与下载(多种上传方式)
  6. 八种 WebSocket 框架的性能比较
  7. 求封闭曲线面积vc代码_圆锥曲线综合5个类型,逐一突破
  8. [ShapeInferenceError] Mismatch between number of source and target dimensions. Source=1 Target=0
  9. Proxy error: Could not proxy request /admin/myResources.do from localhost.jd.com:41000 to http://loc
  10. win2008 mysql_mysql5.7.17在win2008R2的64位系统安装与配置实例
  11. NumPy Beginner's Guide 2e 带注释源码 七、NumPy 特殊例程
  12. SpringMVC4 实例
  13. 数据结构与算法之树的遍历
  14. L1-040 最萌情侣身高差
  15. Windows安装JDK
  16. hdfs的实验总结_HDFS原理及操作
  17. Windows anaconda下载安装
  18. Matlab fprintf
  19. kafka7 探索生产者同步or异步发送消息
  20. 麻雀虽小,五脏俱全:从一个小功能看软件开发过程[转]

热门文章

  1. C语言实现json文本解析
  2. [折腾日记]win10 ,ubuntu双系统安装避坑指南
  3. java dms_奥点云-DMS Java API 文档
  4. 硬盘克隆大师Ghost 8.0技巧从入门到精通
  5. Kaggle泰坦尼克号生存预测挑战——模型建立、模型调参、融合
  6. pbe近似_量子化学中的主要近似.doc
  7. 自学编程的30岁男人,能按应届生那样找工作吗?
  8. 玩客云:更好的迅雷从“共享计算”开始
  9. 我的Python分析成长之路2
  10. IoT原型开发利用现成的单板设计---凯利讯半导体