自定义Cell(完成设置界面)并且自定义一个基类控制器(ZZSettingViewController)(自定义Cell4⃣️)
来源:互联网 发布:服装批发软件手机版 编辑:程序博客网 时间:2024/06/06 15:50
//
// ZZSettingViewController.h
// ZZ_APP主流框架
//
// Created by ZZ_Macpro on 15/10/9.
// Copyright (c) 2015年 ZZ_Macpro. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ZZSettingGroup;
@interface ZZSettingViewController :UITableViewController
@property (nonatomic,strong) NSMutableArray *groups;
- (ZZSettingGroup *)addGroup;
@end
//
// ZZSettingViewController.m
// ZZ_APP主流框架
//
// Created by ZZ_Macpro on 15/10/9.
// Copyright (c) 2015年 ZZ_Macpro. All rights reserved.
//
#import "ZZSettingViewController.h"
#import "ZZSettingGroup.h"
#import "ZZSettingCell.h"
#import "ZZSettingArrowItem.h"
#import "ZZSettingCheckItem.h"
#import "ZZSettingCheckGroup.h"
#define ZZCellMargin 6
@interface ZZSettingViewController ()
@end
@implementation ZZSettingViewController
- (NSMutableArray *)groups
{
if (_groups ==nil) {
_groups = [NSMutableArrayarray];
}
return_groups;
}
- (ZZSettingGroup *)addGroup
{
ZZSettingGroup *group = [ZZSettingGroupgroup];
[self.groupsaddObject:group];
return group;
}
- (id)initWithStyle:(UITableViewStyle)style
{
return [superinitWithStyle:UITableViewStyleGrouped];
}
- (id)init
{
return [superinitWithStyle:UITableViewStyleGrouped];
}
- (void)viewDidAppear:(BOOL)animated
{
[superviewDidAppear:animated];
}
- (void)viewDidLoad
{
[superviewDidLoad];
self.tableView.separatorStyle =UITableViewCellSelectionStyleNone;
self.tableView.backgroundView =nil;
self.view.backgroundColor =ZZGlobalBg;
self.tableView.sectionHeaderHeight =0; //每一组的头部高度
self.tableView.sectionFooterHeight =ZZCellMargin;// 每一组的尾部高度
// 底部控件
UIView *footer = [[UIViewalloc] init];
footer.frame =CGRectMake(0,0, 0,1);
self.tableView.tableFooterView = footer;
if (iOS7) {
self.tableView.contentInset =UIEdgeInsetsMake(ZZCellMargin -33, 0, 0,0);
}else {
self.tableView.contentInset =UIEdgeInsetsMake(ZZCellMargin,0, 0,0);
}
}
#pragma mark ------ Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
returnself.groups.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
ZZSettingGroup *group = self.groups[section];
return group.items.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ZZSettingCell *cell = [ZZSettingCellcellWithTableView:tableView];
cell.indexPath = indexPath;
ZZSettingGroup *group = self.groups[indexPath.section];
cell.item = group.items[indexPath.row];
return cell;
}
#pragma mark ------ 代理
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
ZZSettingGroup *group = self.groups[section];
return group.footer;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
ZZSettingGroup *group = self.groups[section];
return group.header;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPathanimated:YES];
// 0.取出模型
ZZSettingGroup *group = self.groups[indexPath.section];
ZZSettingItem *item = group.items[indexPath.row];
// 1.操作
if (item.option) {
item.option();
}
// 2.跳转
if ([item isKindOfClass:[ZZSettingArrowItemclass]]) {
ZZSettingArrowItem *arrowItem = (ZZSettingArrowItem *)item;
if (arrowItem.destVcClass) {
UIViewController *destVc = [[arrowItem.destVcClassalloc] init];
destVc.title = arrowItem.title;
if (arrowItem.readyForDestVc) {// 控制器的准备工作
arrowItem.readyForDestVc(arrowItem, destVc);
}
[self.navigationControllerpushViewController:destVc animated:YES];
}
}
// 3.check 打勾
if ([item isKindOfClass:[ZZSettingCheckItemclass]]) {
ZZSettingCheckGroup *checkGroup = (ZZSettingCheckGroup *)group;
checkGroup.checkedIndex = indexPath.row;
// 刷新
[tableViewreloadData];
}
}
@end
- 自定义Cell(完成设置界面)并且自定义一个基类控制器(ZZSettingViewController)(自定义Cell4⃣️)
- 自定义Cell(以设置界面为例完成封装)(自定义Cell3⃣️)
- 诸如设置界面自定义Cell模型item封装(所有界面通用)(自定义Cell1⃣️)
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义cell
- 自定义设置界面
- 自定义Cell模型组Group封装(自定义Cell2⃣️)
- tableView 自定义Cell,仿收藏界面
- C#学习之路,学习笔记 第六章 函数
- iOS-使用AudioServices相关接口的连续震动
- Bitmap的一些操作
- 单例模式
- 手动制作根文件系统--之--为开发板制作logo
- 自定义Cell(完成设置界面)并且自定义一个基类控制器(ZZSettingViewController)(自定义Cell4⃣️)
- LightOJ 1005
- UIColor和TintColor
- 类方法、静态方法、实例方法
- stdout&stderr引发的思考
- 计算阶乘中0的个数
- FZU 1056 扫雷游戏
- jdk目录结构
- final