ios Class类型使用
1 #import <Foundation/Foundation.h> 2 3 @interface NJProductItem : NSObject 4 /** 5 * 图标 6 */ 7 @property (nonatomic, copy) NSString *icon; 8 /** 9 * 标题 10 */ 11 @property (nonatomic, copy) NSString *tilte; 12 /** 13 * 目标控制器 14 */ 15 @property (nonatomic, assign) Class destVC; 16 17 18 - (instancetype)initWithIcon:(NSString *)icon title:(NSString *)title destClass:(Class)destVc; 19 @end 20 21 22 23 #import "NJProductItem.h" 24 25 @implementation NJProductItem 26 27 - (instancetype)initWithIcon:(NSString *)icon title:(NSString *)title destClass:(Class)destVc 28 { 29 if (self = [super init]) { 30 self.icon = icon; 31 self.tilte = title; 32 self.destVC = destVc ; 33 } 34 35 return self; 36 37 } 38 @end
1 #import <Foundation/Foundation.h> 2 3 @interface NJProductGroup : NSObject 4 /** 5 * 头部标题 6 */ 7 @property (nonatomic, copy) NSString *headerTitle; 8 /** 9 * 底部标题 10 */ 11 @property (nonatomic, copy) NSString *footerTitle; 12 /** 13 * 当前分组中所有行的数据(保存的是NJProductItem模型) 14 */ 15 @property (nonatomic, strong) NSArray *items; 16 17 @end 18 19 #import "NJProductGroup.h" 20 21 @implementation NJProductGroup 22 23 @end
调用
1 if (_datas == nil) { 2 // 第一组数据 3 NJProductItem *item00 = [[NJProductItem alloc] initWithIcon:@"MorePush" title:@"推送和提醒" destClass:[NJTestViewController class]]; 4 NJProductItem *item01 = [[NJProductItem alloc] initWithIcon:@"MorePush" title:@"摇一摇机选" destClass:[NJTestViewController class]]; 5 6 NJProductGroup *group1 = [[NJProductGroup alloc] init]; 7 group1.items = @[item00 ,item01]; 8 9 // 第2组数据 10 NJProductItem *item10 = [[NJProductItem alloc] initWithIcon:@"MorePush" title:@"检查新版本" destClass:[NJTestViewController class]]; 11 NJProductGroup *group2 = [[NJProductGroup alloc] init]; 12 group2.headerTitle = @"第2组的标题"; 13 group2.footerTitle = @"第2组的标题123456"; 14 group2.items = @[item10]; 15 16 _datas = [NSMutableArray array]; 17 [_datas addObject:group1]; 18 [_datas addObject:group2]; 19 20 } 21 return _datas; 22 23 24 25 // 先取出对应组的组模型 26 NJProductGroup *g = self.datas[indexPath.section]; 27 // 从组模型中取出对应行的模型 28 NJProductItem *item = g.items[indexPath.row]; 29 // 创建目标控制并且添加到栈中 30 UIViewController *vc = [[item.destVC alloc] init]; 31 [self.navigationController pushViewController:vc animated:YES];
转载于:https://www.cnblogs.com/PJHome/p/5155643.html
ios Class类型使用相关推荐
- iOS 字体类型列表
iOS 中自带的字体类型大全(UIFont) Font Family: American Typewriter Font: AmericanTypewriter Font: AmericanTyp ...
- iOS SEL类型和创建
SEL selAction =NSSelectorFromString([actionArrayobjectAtIndex:indexArray]); [item addTarget:self act ...
- uniapp苹果端IOS日期类型显示NAN
把所有用到的日期类型为YYYY-MM-DD的全部改成用'/'即可解决 new Date(date.replace(/-/g, "/"))
- iOS: 枚举类型 enum,NS_ENUM,NS_OPTIONS
一般情况下,我们采用C风格的enum关键字可以定义枚举类型. enum{ UIViewAnimationTransitionNone,UIViewAnimationTransitionFlipFrom ...
- IOS属性类型的讲解
http://www.2cto.com/kf/201205/133943.html
- iOS越狱过程:越狱工具做了什么事情?( iOS系统结构、常见的二进制文件类型)
文章目录 前言 I 什么是越狱? 1.1 越狱破坏了 iOS 系统的哪些保护机制 1.2 攻击的目标 1.3 越狱工具做的事情 II iOS系统结构 III iOS二进制文件类型 3.1 bundle ...
- iOS开发系列--通知与消息机制
http://www.cocoachina.com/ios/20150318/11364.html 概述 在多数移动应用中任何时候都只能有一个应用程序处于活跃状态,如果其他应用此刻发生了一些用户感兴趣 ...
- iOS UITouch触摸与UIGesture手势.01.事件、触摸(touch)事件
一.iOS事件: 1.事件:事件就是当你在手机上点击手机屏幕.滑动手机翻面.摇动手机的时候,手机做出一些反应,对应的在应用程序里实现了某些代码的某些功能,完成这个过程就是一个事件. 2.iOS事件类型 ...
- iOS用户设计指南 - 平台特征
iOS系统的设备有一些特有的特征,影响着所有在其上面运行的应用程序的用户体验.大部分的热门应用,都是做到了很好的与这些特征的融合. 屏幕尺寸 设备的屏显是影响用户体验的重中之重.不仅是用户能通过视觉感 ...
最新文章
- 黑帽与白帽始终有着“差别”
- mysql防注入原理_MyBatis如何防止SQL注入
- 章琦:能坚持的唯一的原因就是兴趣
- Hadoop机架感知
- PHP JSON数组与对象的理解
- 这样的Softmax你真的不了解!
- C/C++链接过程相关
- 卓越产品计划丨神策分析性能优化详解:数据重组织查询优化
- java面经2020
- 贝叶斯公式的通俗理解
- wpf 客户端 添加qq客服咨询
- 2019python二级真题_2019年3月二级python真题,上岸必备!
- Word插入页码、插图清单目录、附表清单
- Python代码编辑器jupyter的使用
- Quorum工作原理
- android 系统重新安装程序,Android应用程序更新时的安装与卸载(调用系统方法)...
- 倍福--授权文件拷贝
- 【论文解读:bCNN-Methylpred: Feature-Based Prediction of RNA Sequence Modification Using Branch Convoluti】
- Mac如何安装MySQL和Navicat
- 吴恩达《机器学习系列课程》学习笔记(一)
热门文章
- 鼠标控制程序,按住shift显示S,按住Ctrl显示C,按键盘显示D,松开键盘显示U
- 信息量、熵、相对熵与交叉熵的理解
- 基于机器学习的GitHub敏感信息泄露监控
- java 异常哪个包,这个提示包不存在的异常是咋回事
- oracle 开并行写入命令,Oracle等待事件“日志文件并行写入”更改
- lambda函数if_Lambda函数用法总结
- 修改Ubuntu下的jenkins端口号
- 可以储存照片的字段类型是_在sql server中,储存图片的数据类型是什么呀?
- 项目中遇到的所有ECharts图表集合
- 企业Linux系统部署OA系统上线实例