文章来源:淘论文网   发布者: 毕业设计   浏览量: 88



还可以点击去查询以下关键词:
[静态]    [页面]    [大杀]    [静态页面大杀器]   

项目介绍:

StaticPage

静态页面大杀器,采用该库三行代码就能搞定通用静态页面

如何使用StaticPage

首先先把你控制器中tableview的类型设置为UITableViewStyleGrouped类型

_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];

只需要导入ICCommonItemCell.h头文件

import 'ICCommonItemCell.h'

然后在你的数据源中根据分组来设置相应的数据,例如demo中的代码:

-(NSMutableArray *)dataArray { if (nil == _dataArray) { _dataArray = [NSMutableArray array]; ICCommonItem *friendItem = [ICSettingArrowItem itemWithIcon:@'ff_IconShowAlbum' title:@'朋友圈' destVcClass:[ICTestViewController class] parameter:@'朋友圈']; // 根据要跳转的控制器需要的参数类型,具体填写,我这里需要的是字符串类型,就传递的字符串 ICCommonGroup *friendGroup = [[ICCommonGroup alloc] init]; friendGroup.items = @[friendItem]; ICCommonItem *sweepItem = [ICSettingArrowItem itemWithIcon:@'ff_IconQRCode' title:@'扫一扫' destVcClass:[ICTestViewController class] parameter:@'扫一扫']; ICCommonItem *waveItem = [ICSettingArrowItem itemWithIcon:@'ff_IconShake' title:@'摇一摇' destVcClass:[ICTestViewController class] parameter:@'摇一摇']; ICCommonGroup *sewaGroup = [[ICCommonGroup alloc] init]; sewaGroup.items = @[sweepItem,waveItem]; ICCommonItem *nearItem = [ICSettingArrowItem itemWithIcon:@'ff_IconLocationService' title:@'附近的人' destVcClass:[ICTestViewController class] parameter:@'附近的人']; ICCommonItem *driftItem = [ICSettingArrowItem itemWithIcon:@'ff_IconBottle' title:@'漂流瓶' destVcClass:[ICTestViewController class] parameter:@'漂流瓶']; ICCommonGroup *nedrGroup = [[ICCommonGroup alloc] init]; nedrGroup.items = @[nearItem,driftItem]; ICCommonItem *shopItem = [ICSettingArrowItem itemWithIcon:@'ff_IconQRCode' title:@'购物' destVcClass:[ICTestViewController class] parameter:@'购物']; ICCommonItem *gameItem = [ICSettingArrowItem itemWithIcon:@'MoreGame' title:@'游戏' destVcClass:[ICTestViewController class] parameter:@'游戏']; ICCommonGroup *shgaGroup = [[ICCommonGroup alloc] init]; shgaGroup.items = @[shopItem,gameItem]; [_dataArray addObject:friendGroup]; [_dataArray addObject:sewaGroup]; [_dataArray addObject:nedrGroup]; [_dataArray addObject:shgaGroup]; } return _dataArray; }

其中ICCommonGroup对应一组,而ICCommonItem又对应组中的每一个Item,每个Item有两种类型
,分别为ICSettingArrowItem和ICSettingSwitchItem;

+ (instancetype)itemWithIcon:(NSString *)icon title:(NSString *)title destVcClass:(Class)destVcClass parameter:(id)parameter;

这个方法中的参数含义:

icon:cell中左边图片的图片名

title:cell的title显示的字符串内容

destVcClass:点击cell时要跳转的控制器类型

parameter:点击cell时要跳转时需要传递过去的参数

如果ICCommonItem中存在ICSettingSwitchItem,为了扑捉到UISwitch的开关事件,你需要遵守ICCommonItemCellDelegate,实现其中的代理方法:

- (void)commonItemCell:(ICCommonItemCell *)cell swith:(UISwitch *)swith;

如果想要改变每个组之间的间距(是组不是每个Item)你可以重写tableview的两个代理方法,论文开题报告,返回自己想要的间距即可:

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {} - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {}

每个Item还可以在其对应的block中响应对应的事件,这样只需在tableview的didSelected方法中调用option这个block即可;

如果你需要显示区头或者区尾,只需要在数据源中给对用的group设置header或footer即可:

ICCommonItem * discover = [ICSettingSwitchItem itemWithIcon:nil title:@'置顶会话' destVcClass:nil parameter:nil]; ICCommonItem *companyDoc = [ICSettingSwitchItem itemWithIcon:nil title:@'消息免打扰' destVcClass:nil parameter:nil]; ICCommonGroup * mesGroup = [[ICCommonGroup alloc] init]; mesGroup.header = @'来个区头玩玩'; mesGroup.items = @[discover,companyDoc];

然后在tableview的代理方法中调用即可:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { ICCommonGroup *group = self.dataArray[section]; return group.header; } - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { ICCommonGroup *group = self.dataArray[section]; return group.footer; }

如果你在使用过程中遇到什么问题您可以issues提问,如果你想贡献代码请pull Reques;

github地址:https://github.com/corderguo/StaticPage


这里还有:


还可以点击去查询:
[静态]    [页面]    [大杀]    [静态页面大杀器]   

请扫码加微信 微信号:sj52abcd


下载地址: http://www.taolw.com/down/7505.docx
  • 上一篇:【Swift3.0+ RxSwift +MVVM 】Gank客户端
  • 下一篇:通用聊天框架搭建,实定制现微信聊天的所用功能!