关于 LYCHolyContentController 的使用记录

通过多次实践后,会开始萌发一种设计框架的想法。

其实也没有什么高上档的,也就是为了可以更加懒惰,过的更加快乐而已。

思路很简单,控制加载过程,以及自动执行释放的事件。

补充:

方便、快速、优化、强大的设计是需要很多实践来测试、维护、修改来确定的。

下面上代码了。

//
//  MainController.h
//  某项目
//
//  Created by yococo on 3/7/15.
//  Copyright (c) 2015 yococo. All rights reserved.
//

#import "LYCHolyContentController.h"

@interface MainController : LYCHolyContentController

+ (MainController *)sharedInstance;

@end
//
//  MainController.m
//  某项目
//
//  Created by yococo on 3/7/15.
//  Copyright (c) 2015 yococo. All rights reserved.
//

#import "MainController.h"

#import "IndexController.h"
#import "BrandController.h"
#import "LocationController.h"
#import "ProjectController.h"
#import "SmartController.h"
#import "StrollController.h"
#import "FormatsController.h"
#import "PropertyController.h"

#import "MainModel.h"

@interface MainController ()<LYCHolyContentControllerDelgate>

//  需要加载的对象
@property (nonatomic, strong) IndexController *indexController;
@property (nonatomic, strong) BrandController *brandController;
@property (nonatomic, strong) LocationController *locationController;
@property (nonatomic, strong) ProjectController *projectController;
@property (nonatomic, strong) SmartController *smartController;
@property (nonatomic, strong) StrollController *strollController;
@property (nonatomic, strong) FormatsController *formatsController;
@property (nonatomic, strong) PropertyController *propertyController;

@end

@implementation MainController

+ (MainController *)sharedInstance
{
    static MainController *singleton;
    static dispatch_once_t token;
    dispatch_once(&token,^{
        singleton = [MainController LYCControllerWithViewDirectionHorizontal];
    });
    return singleton;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)loadView
{
    [super loadView];

    //  设置协议
    self.lycHolyContentControllerDelgate = self;

    //  设置控制视图的大小位置
    CGRect tempRect = self.lycHolyControlView.frame;
    tempRect.size.height = 75;
    tempRect.origin.y = self.lycCurrentBounds.size.height - 75;
    self.lycHolyControlViewRect = tempRect;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    //  触发按钮事件。
    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - 设置按钮
- (NSArray *)lycHolyContentController:(LYCHolyContentController *)contentController buttonOnControlView:(UIView *)view
{
    return [MainModel controlButtons];
}

#pragma mark - 设置控制视图背景图
- (void)lycHolyContentController:(LYCHolyContentController *)contentController controlBackgroundImageView:(UIImageView *)imageView
{
    imageView.image = [UIImage LYCImageWithDatasource:LYC__PathFromBundleAppendingPathComponent(@"导航背景.png")];
}

#pragma mark - 设置按钮触发事件
- (void)lycHolySystemEventLoadViewControllerWithButton:(LYCHolyButton *)button
{
    switch (button.lycHolyIdentificationStyle) {
        case LYCHolyIdentificationStyleIndex:
        {
            //  不隐藏控制视图
            self.lycHolyControlViewHidden = NO;

            //  设置按钮状态
            [self lycHolyShowButtonSelectedState];

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 IndexController对象
                self.indexController = [IndexController LYCControllerXIBWithViewDirectionHorizontal];
                [self.indexController lycUnloadViewControllerWithBlock:^{
                    //  卸载 IndexController对象后,加载 SmartController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleNews];
                }];
            } complete:^{
                //  加载 IndexController对象
                [self lycHolyAddViewController:self.indexController];
            }];
        }
            break;
        case LYCHolyIdentificationStyleBrand:
        {
            //  不隐藏控制视图
            self.lycHolyControlViewHidden = NO;

            //  设置按钮状态
            [self lycHolyShowButtoNormalStateAndOthersSelectedStateWithCurrentIdentificationStyle];

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 BrandController对象
                self.brandController = [BrandController LYCControllerXIBWithViewDirectionHorizontal];
                [self.brandController lycUnloadViewControllerWithBlock:^{
                    //  卸载 BrandController对象后,加载 IndexController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
                }];
            } complete:^{
                //  加载 BrandController对象
                [self lycHolyAddViewController:self.brandController];
            }];
        }
            break;
        case LYCHolyIdentificationStyleLocation:
        {
            //  隐藏控制视图
            self.lycHolyControlViewHidden = YES;

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 LocationController对象
                self.locationController = [LocationController LYCControllerXIBWithViewDirectionHorizontal];
                [self.locationController lycUnloadViewControllerWithBlock:^{
                    //  卸载 LocationController对象后,加载 IndexController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
                }];
            } complete:^{
                //  加载 LocationController对象
                [self lycHolyAddViewController:self.locationController];
            }];
        }
            break;
        case LYCHolyIdentificationStyleProject:
        {
            //  隐藏控制视图
            self.lycHolyControlViewHidden = YES;

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 ProjectController对象
                self.projectController = [ProjectController LYCControllerXIBWithViewDirectionHorizontal];
                [self.projectController lycUnloadViewControllerWithBlock:^{
                    //  卸载 ProjectController对象后,加载 IndexController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
                }];
            } complete:^{
                //  加载 ProjectController对象
                [self lycHolyAddViewController:self.projectController];
            }];
        }
            break;
        case LYCHolyIdentificationStyleSmart:
        {
            //  隐藏控制视图
            self.lycHolyControlViewHidden = YES;

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 SmartController对象
                self.smartController = [SmartController LYCControllerXIBWithViewDirectionHorizontal];
                [self.smartController lycUnloadViewControllerWithBlock:^{
                    //  卸载 SmartController对象后,加载 IndexController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
                }];
            } complete:^{
                //  加载 SmartController对象
                [self lycHolyAddViewController:self.smartController];
            }];
        }
            break;
        case LYCHolyIdentificationStyleStroll:
        {
            //  不隐藏控制视图
            self.lycHolyControlViewHidden = NO;

            //  设置按钮状态
            [self lycHolyShowButtoNormalStateAndOthersSelectedStateWithCurrentIdentificationStyle];

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 StrollController对象
                self.strollController = [StrollController LYCControllerXIBWithViewDirectionHorizontal];
                [self.strollController lycUnloadViewControllerWithBlock:^{
                    //  卸载 StrollController对象后,加载 IndexController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
                }];
            } complete:^{
                //  加载 StrollController对象
                [self lycHolyAddViewController:self.strollController];
            }];
        }
            break;
        case LYCHolyIdentificationStyleFormats:
        {
            //  不隐藏控制视图
            self.lycHolyControlViewHidden = NO;

            //  设置按钮状态
            [self lycHolyShowButtoNormalStateAndOthersSelectedStateWithCurrentIdentificationStyle];

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 FormatsController对象
                self.formatsController = [FormatsController LYCControllerXIBWithViewDirectionHorizontal];
                [self.formatsController lycUnloadViewControllerWithBlock:^{
                    //  卸载 FormatsController对象后,加载 IndexController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
                }];
            } complete:^{
                //  加载 FormatsController对象
                [self lycHolyAddViewController:self.formatsController];
            }];
        }
            break;
        case LYCHolyIdentificationStyleProperty:
        {
            //  不隐藏控制视图
            self.lycHolyControlViewHidden = NO;

            //  设置按钮状态
            [self lycHolyShowButtoNormalStateAndOthersSelectedStateWithCurrentIdentificationStyle];

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 PropertyController对象
                self.propertyController = [PropertyController LYCControllerXIBWithViewDirectionHorizontal];
                [self.propertyController lycUnloadViewControllerWithBlock:^{
                    //  卸载 PropertyController对象后,加载 IndexController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
                }];
            } complete:^{
                //  加载 PropertyController对象
                [self lycHolyAddViewController:self.propertyController];
            }];
        }
            break;
        case LYCHolyIdentificationStyleNews:
        {
            //  隐藏控制视图
            self.lycHolyControlViewHidden = YES;

            [self lycHolyLoadViewControllerWithButton:button initialization:^{
                //  初始化 SmartController对象
                self.smartController = [SmartController CustomController];
                [self.smartController lycUnloadViewControllerWithBlock:^{
                    //  卸载 SmartController对象后,加载 IndexController对象
                    [self lycHolyLoadViewControllerWithIdentificationStyle:LYCHolyIdentificationStyleIndex];
                }];
            } complete:^{
                //  加载 SmartController对象
                [self lycHolyAddViewController:self.smartController];
            }];
        }
            break;

        default:
            break;
    }
}

#pragma mark - 设置释放事件
- (void)lycHolySystemEventReleaseViewControllerWithIdentificationStyle:(LYCHolyIdentificationStyle)identificationStyle
{
    switch (identificationStyle) {
        case LYCHolyIdentificationStyleIndex:
        {
            LYC__Holy__ViewControllerRelease(self.indexController)
        }
            break;
        case LYCHolyIdentificationStyleBrand:
        {
            LYC__Holy__ViewControllerRelease(self.brandController)
        }
            break;
        case LYCHolyIdentificationStyleLocation:
        {
            LYC__Holy__ViewControllerRelease(self.locationController)
        }
            break;
        case LYCHolyIdentificationStyleProject:
        {
            LYC__Holy__ViewControllerRelease(self.projectController)
        }
            break;
        case LYCHolyIdentificationStyleSmart:
        {
            LYC__Holy__ViewControllerRelease(self.smartController)
        }
            break;
        case LYCHolyIdentificationStyleStroll:
        {
            LYC__Holy__ViewControllerRelease(self.strollController)
        }
            break;
        case LYCHolyIdentificationStyleFormats:
        {
            LYC__Holy__ViewControllerRelease(self.formatsController)
        }
            break;
        case LYCHolyIdentificationStyleProperty:
        {
            LYC__Holy__ViewControllerRelease(self.propertyController)
        }
            break;
        case LYCHolyIdentificationStyleNews:
        {
            LYC__Holy__ViewControllerRelease(self.smartController)
        }
            break;

        default:
            break;
    }
}

@end

下面是负责数据源的。

//
//  MainModel.h
//  某项目
//
//  Created by yococo on 3/7/15.
//  Copyright (c) 2015 yococo. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface MainModel : NSObject

+ (NSArray *)controlButtons;

@end
//
//  MainModel.m
//  某项目
//
//  Created by yococo on 3/7/15.
//  Copyright (c) 2015 yococo. All rights reserved.
//

#import "MainModel.h"

#import "LYCHolyButton.h"

@implementation MainModel

+ (NSArray *)controlButtons
{
    NSMutableArray *array = [NSMutableArray array];
    /*********   Add  Start   ********/
    LYCHolyButton *button_index = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(52, 18, 0, 50) identificationStyle:LYCHolyIdentificationStyleIndex];
    [array addObject:button_index];
    button_index = nil;
    /*********   Add  End   ********/
    /*********   Add  Start   ********/
    LYCHolyButton *button_brand = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(52, 18, 100, 50) identificationStyle:LYCHolyIdentificationStyleBrand];
    button_brand.lycHolyImageNormalPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_01_半暗.png");
    button_brand.lycHolyImageSelectedPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_01_正常.png");
    [array addObject:button_brand];
    button_brand = nil;
    /*********   Add  End   ********/
    /*********   Add  Start   ********/
    LYCHolyButton *button_location = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(183, 18, 100, 50) identificationStyle:LYCHolyIdentificationStyleLocation];
    button_location.lycHolyImageNormalPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_02_半暗.png");
    button_location.lycHolyImageSelectedPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_02_正常.png");
    [array addObject:button_location];
    button_location = nil;
    /*********   Add  End   ********/
    /*********   Add  Start   ********/
    LYCHolyButton *button_project = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(321, 18, 100, 50) identificationStyle:LYCHolyIdentificationStyleProject];
    button_project.lycHolyImageNormalPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_03_半暗.png");
    button_project.lycHolyImageSelectedPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_03_正常.png");
    [array addObject:button_project];
    button_project = nil;
    /*********   Add  End   ********/
    /*********   Add  Start   ********/
    LYCHolyButton *button_smart = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(455, 18, 100, 50) identificationStyle:LYCHolyIdentificationStyleSmart];
    button_smart.lycHolyImageNormalPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_04_半暗.png");
    button_smart.lycHolyImageSelectedPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_04_正常.png");
    [array addObject:button_smart];
    button_smart = nil;
    /*********   Add  End   ********/
    /*********   Add  Start   ********/
    LYCHolyButton *button_stroll = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(592, 18, 100, 50) identificationStyle:LYCHolyIdentificationStyleStroll];
    button_stroll.lycHolyImageNormalPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_05_半暗.png");
    button_stroll.lycHolyImageSelectedPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_05_正常.png");
    [array addObject:button_stroll];
    button_stroll = nil;
    /*********   Add  End   ********/
    /*********   Add  Start   ********/
    LYCHolyButton *button_formats = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(725, 18, 100, 50) identificationStyle:LYCHolyIdentificationStyleFormats];
    button_formats.lycHolyImageNormalPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_06_半暗.png");
    button_formats.lycHolyImageSelectedPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_06_正常.png");
    [array addObject:button_formats];
    button_formats = nil;
    /*********   Add  End   ********/
    /*********   Add  Start   ********/
    LYCHolyButton *button_property = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(864, 18, 100, 50) identificationStyle:LYCHolyIdentificationStyleProperty];
    button_property.lycHolyImageNormalPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_07_半暗.png");
    button_property.lycHolyImageSelectedPath = LYC__PathFromBundleAppendingPathComponent(@"导航按钮_07_正常.png");
    [array addObject:button_property];
    button_property = nil;
    /*********   Add  End   ********/
    /*********   Add  Start   ********/
    LYCHolyButton *button_news = [LYCHolyButton LycHolyButtonWithFrame:CGRectMake(964, 18, 0, 50) identificationStyle:LYCHolyIdentificationStyleNews];
    [array addObject:button_news];
    button_news = nil;
    /*********   Add  End   ********/

    return array;
    return nil;
}

@end

已经通过某项目实践过,更新了过一些细节修改。

本设计使用了个人Kit:LYCKit。

作者:木子才

时间: 2024-10-02 00:59:23

关于 LYCHolyContentController 的使用记录的相关文章

老男孩Linux运维第41期20170917开班第四周学习重点课堂记录

第1章 必知必会文件 配置文件位置 该文件作用 /etc/sysconfig/network-scripts/ifcfg-eth0 第一块网卡的配置文件 同setup中的network /etc/resolv.conf 客户端DNS配置文件,优先级低于网卡配置文件 /etc/hosts 主要作用是定义IP地址和主机名的映射关系(域名解析),是一个映射IP地址和主机名的规定 /etc/sysconfig/network 用于配置hostname和networking /etc/fstab 开机自动

SSISDB8:查看SSISDB记录Package执行的消息

在执行Package时,SSISDB都会创建唯一的OperationID 和 ExecutionID,标识对package执行的操作和执行实例(Execution Instance),并记录operation message,统计executable的执行时间,便于developers 优化package的设计,对package进行故障排除. 一,在package发生错误时,查看失败的Executable An executable is a task or container that you

使用插件bootstrap-table实现表格记录的查询、分页、排序等处理

在业务系统开发中,对表格记录的查询.分页.排序等处理是非常常见的,在Web开发中,可以采用很多功能强大的插件来满足要求,且能极大的提高开发效率,本随笔介绍这个bootstrap-table是一款非常有名的开源表格插件,在很多项目中广泛的应用.Bootstrap-table插件提供了非常丰富的属性设置,可以实现查询.分页.排序.复选框.设置显示列.Card view视图.主从表显示.合并列.国际化处理等处理功能,而且该插件同时也提供了一些不错的扩展功能,如移动行.移动列位置等一些特殊的功能,插件可

Git 使用记录

在win7平台已经安装好了git的情况下: 1,Git 本地仓库建立与使用步骤: (2)新建立文件夹: $ mkdir learngit $ cd learngit $ pwd /Users/michael/learngit (1)引入git: 通过git init命令把这个目录变成Git可以管理的仓库: $ git init Initialized empty Git repository in /Users/michael/learngit/.git/ (3)添加文件:git add fil

前端学HTTP之日志记录

前面的话 几乎所有的服务器和代理都会记录下它们所处理的HTTP事务摘要.这么做出于一系列的原因:跟踪使用情况.安全性.计费.错误检测等等.本文将谥介绍日志记录 记录内容 大多数情况下,日志的记录出于两种原因:査找服务器或代理中存在的问题(比如,哪些请求失败了),或者是生成Web站点访问方式的统计信息.统计数据对市场营销.计费和容量规划(比如,决定是否需要增加服务器或带宽)都非常有用 可以把一个HTTP事务中所有的首部都记录下来,但对每天要处理数百万个事务的服务器和代理来说,这些数据的体积超大,很

ClientDataSet中动态添加计算字段并用计算字段显示记录的UpdateStatus

ClientDataSet中每条记录都有UpdateStatus=(usUnmodified, usModified, usInserted, usDeleted)记录该条数据是修改的,删除的,还是新增的等.有时候我们只想看修改的或新增的或删除的就可能用到这一属性.下图用计算字段显示UpdateStatus状态. ********************************************************************************************

MySQL删除重复记录的方法

参考网上的方法,总结了产出重复记录的方法,欢迎交流. 方法1:创建一个新表临时储存数据 假设我们有一个存在多个字段的表,表中有部分数据的若干字段重复,此时我们可以使用DISTINCT这个关键字对表数据进行筛选. 1 CREATE [TEMPORARY] TABLE temp LIKE origin_tb; 2 INSERT temp(attr1,attr2,...) SELECT DISTINCT attr1,attr2,... FROM origin_tb; 3 DELETE FROM ori

北塔网管软件BTSO2.5安装过程记录

北塔网管软件据说是同类比较好的,原来的BTIM系列好像停止更新了,用BTSO版本代替,叫智慧运维平台,据说有各种改进,先把安装过程记录下来,以备以后重装. BTSO分两个部分:平台服务器和注册服务器,可以安装到一台主机,也可以分开,他们要能够通讯,否则认为盗版,注册要记录系统环境.要识别原版光盘,反正国产的软件版权意识近乎变态. 说明上要求win2008r2ent中文版或者win2012企业中文版,先试了2012,注册菜单不出现,重新用2008安装.顺序如下: 1.安装BETA-BTSO_2.5

Python学习记录-2016-12-17

今日学习记录 模块: import os#导入os模块 import sys#导入sys模块 os.system("df -h")#执行df -h命令 cmd_res = os.popen("df -h").read()#将命令的返回结果赋值给cmd_res,如果不加入.read()会显示命令的返回加过在内存的位置 print(sys.path)#显示系统变量路径,一般个人模块位于site-packages下,系统模块位于lib下 print(sys.argu[2]