网易彩票开发知识点总结

关于网易彩票开发中遇到了不少的坑,弄了好久才弄懂,或者有些犹豫很久没用就不记得了,所以这里就总结了一下,希望以后不会忘记,就算忘记也能快速查看!

/***************************************&.设置状态栏样式(白色) 两种方法******************************************/

 -(UIStatusBarStyle)preferredStatusBarStyle

 {

     if ([self isEqualToFirstChildTabBarController]) {

             return UIStatusBarStyleDefault;

         } else {

             return UIStatusBarStyleLightContent;

         }

     //    if (self.tabBarController.selectedIndex == 0) {

     //        return UIStatusBarStyleDefault;

     //    } else {

     //        return UIStatusBarStyleLightContent;

     //    }

 }

 -(BOOL)prefersStatusBarHidden

 {

     return NO;

 }

•在要info.plist文件添加一个配置View controller-based status bar appearance = NO;

>如果有导航控制器,状态栏的样式由"导航控制器" 决定,而不是由导航控制器的"子控制器"

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

[UIApplication sharedApplication].statusBarHidden = NO;

/************************************&修改系统默认的导航栏:使用KVC*************************************************/

iCocosNavigationBar *bar = [[iCocosNavigationBar alloc] init];

[self setValue:bar forKey:@"navigationBar"];

/*********************************************&取消高亮效果****************************************************/

 //取消系统实现的高亮效果

 -(void)setHighlighted:(BOOL)highlighted

 {

 }

/******************** ****************&关于按钮选中的三部曲************************ ***********************************/

 //设置之前的不选中

 self.selectedBtn.selected = NO;

 //设置当前按钮选中

 btn.selected = YES;

 //设置当前选中的为按钮

 self.selectedBtn = btn;

/********************************&设置导航栏左右控制器的布局*****************************************************/

 //遍历所有子控件

 for (UIView *subView in self.subviews) {

     //如果是左边的控制器

     if ([subView isKindOfClass:[iCocosnavigationLeftButton class]]) {

         CGRect leftRect = subView.frame;

         leftRect.origin.x = margin;

         subView.frame = leftRect;

     }

     //如果是右边的控制器

     if ([subView isKindOfClass:[iCocosnavigationRightButton class]]) {

         CGRect rightRect = subView.frame;

         rightRect.origin.x = self.frame.size.width - margin - rightRect.size.width;

         subView.frame = rightRect;

     }

 }

/********************** ***************&设置导航栏主题样式(重点)******************** ********************************/

 //获取导航栏主题

 UINavigationBar *appearance = [UINavigationBar appearance];

 //设置导航栏背景主题

 [appearance setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];

 //使用键值对的方式设置导航栏字体的颜色和大小

 NSMutableDictionary *dic = [NSMutableDictionary dictionary];

 dic[NSForegroundColorAttributeName] = [UIColor whiteColor];

 //    dic[NSFontAttributeName] = [UIFont systemFontOfSize:15];

 dic[NSFontAttributeName] = [UIFont fontWithName:];

 [appearance setTitleTextAttributes:dic];

//导航栏左右按钮(标题按钮颜色)

[appearance setTintColor:[UIColor whiteColor]];

// 1.1.设置背景颜色

  • * 在ios6以前,包括ios6,导航栏背景图片的高度44(标准)
  • * 在ios7以后,导航栏背景图片的高度64(标准)
 // 局部方式

 //    [navBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];

 //=========== 第一方法设置导航栏样式 (全局方式)==============

 // 2.1获取导航栏

 //    navBar = [UINavigationBar appearance];

 //

 //    [navBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];

#warning 要求,设置导航栏背景图片只要调用一次

  • 1> 在didFinishLaunchingWithOptions执行
  • 2> 在导航控制器的initialize (建议在此方法实现导航栏样式设置)
  • 3> 自定义的导航栏样式类

/********************** ********&使用代理的方式实现点击对应的tabBar跳到对应的控制器**************************** ***************/

 ):创建一个协议

 @class iCocosTabBar;

 @protocol iCocosTabBarDelegate <NSObject>

 @optional

 -(void)iCocosTabBar:(iCocosTabBar *)tabBar selectIndex:(NSInteger)selectindex;

 @end

 ):创建一个代理属性

 @property (nonatomic, weak) id<iCocosTabBarDelegate> delegate;

 ):判断是否实现代理方法

 if ([self.delegate respondsToSelector:@selector(iCocosTabBar:selectIndex:)]) {

     [self.delegate iCocosTabBar:self selectIndex:btn.tag];

     self.tabBarController.selectedIndex = btn.tag;

 }

 ):遵守协议,设置代理对应,实现代理方法

 <iCocosTabBarDelegate>

 tabBar.delegate = self;

 -(void)iCocosTabBar:(iCocosTabBar *)tabBar selectIndex:(NSInteger)selectindex

 {

     self.selectedIndex = selectindex;

 }

/**************** **************&使用属性的方式实现点击对应的按钮跳转到对应的界面**************** ***************************/

 ):创建一个控制器属性

 @property (nonatomic, weak) UITabBarController *tabBarController;

 ):设置对应控制器属性的选中为按钮对应的tag

 self.tabBarController.selectedIndex = btn.tag;

 ):让tabBar的这个属性成为我们自己创建的那个(他自己)

 tabBar.tabBarController = self;

发现Cell时动态的,设置自定义的控制器之后发现数据不显示,解决办法:注释或者删除对应tableView控制器中实现的代理方法

/*************** **********************************&****************** *****************************************/

tableView顶部间距-(和导航栏)是35,tableview上移动(edgninset)35的时候cell顶部和导航栏地步对应,所以这个时候顶部个屏幕顶部是29!

静态tableView顶部和导航栏的底部对其,即y=64

/************** **********************************&***************************** **************************/

tableView属性设置


 self.tableView.contentInset = UIEdgeInsetsMake(-, , , );

 self.tableView.sectionHeaderHeight =;

/************************** ***********************&*********************** ********************************/

通知传值:带参数

 -(void)addiCocosCheckSelectionNotification

 {

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(iCocosCheckSelection:) name:iCocosCheckSelectionNotification object:nil];

 }

 -(void)iCocosCheckSelection:(NSNotification *)noti

 {

     id checkCell = noti.userInfo[@"CheckCell"];

     if (checkCell != self) {

         self.iCocosCheck.selected = NO;

     }

 }

 -(void)dealloc

 {

     [[NSNotificationCenter defaultCenter] removeObserver:self];

 }

 NSDictionary *userInfo = @{@"CheckCell":cell};

 [[NSNotificationCenter defaultCenter] postNotificationName:iCocosCheckSelectionNotification object:nil userInfo:userInfo];

/*************************** *********************&******************** **********************************/

Block传值:切换控制器

 //使用block传值

 @property (nonatomic, strong) void(^operationBlock)(NSIndexPath *indexpath);

 //typedef void(^operationBlock)(NSIndexPath *indexpath);

 //@property (nonatomic, copy) operationBlock block;

// 保存一个跳转的控制器类名,1.字符串 2.Class

/** 目的控制器的类名 Class:一般用assign */

@property (nonatomic, assign) Class descVc;

 #pragma mark - 监听cell点击

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

 {

     [tableView deselectRowAtIndexPath:indexPath animated:YES];

     // 取出模型

     XMGGroupItem *group = self.groups[indexPath.section];

     XMGSettingItem *item = group.items[indexPath.row];

     // 判断下有木有事情,就判断下block有没有值

     if (item.operationBlock) {

         // 执行保存的代码

         item.operationBlock(indexPath);

         return;

     }

     if ([item isKindOfClass:[XMGSettingArrowItem class]]) {

         XMGSettingArrowItem *arrowItem = (XMGSettingArrowItem *)item;

         if (arrowItem.descVc) {

             // 创建目的控制器

             UIViewController *vc = [[arrowItem.descVc alloc] init];

             vc.navigationItem.title = item.title;

             // 跳转界面

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

         }

     }

 }
 __weak typeof(self) weakSelf = self;

 // 在block中最好不要直接访问成员属性

 RedeemCode.operationBlock = ^(NSIndexPath *indexPath){

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

     vc.view.backgroundColor = [UIColor redColor];

     vc.title = @"asldjasd";

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

     // self -> _groups

     NSLog(@"%@",weakSelf.groups);

 };

 //

 //// 保存检查新版本需要做的事情

 //version.operationBlock = ^(NSIndexPath *indexPath){

 //    [MBProgressHUD showSuccess:@"没有最新的版本"];

 //};

 // 设置目的控制器的类名

 push.descVc = [XMGPushViewController class];

/************************* ********************&************************** *******************************/

使用属性的方式实现控制器去的切换

 @property (nonatomic, assign) Class destinationControllerClass;

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

 {

     iCocosSettingGroupModel *group = self.groups[indexPath.section];

     iCocosSettingCellModel *item = group.items[indexPath.row];

     if (item.destinationControllerClass) {

         id dest = [[item.destinationControllerClass alloc] init];

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

     }

     if ([item isKindOfClass:[iCocosSettingCheckModel class]]) {

         iCocosSettingCell *cell = (iCocosSettingCell *)[tableView cellForRowAtIndexPath:indexPath];

         if (!cell.iCocosCheck.selected) {

             //            if (cell.iCocosCheck.selected == nil) {

             cell.iCocosCheck.selected = !cell.iCocosCheck.selected;

             NSDictionary *userInfo = @{@"CheckCell":cell};

             [[NSNotificationCenter defaultCenter] postNotificationName:iCocosCheckSelectionNotification object:nil userInfo:userInfo];

         }

     }

 }

item1.destinationControllerClass = [iCocosPushController class];

/********************** ************************&******************* ***********************************/

模型实现方法,关于值的存在与否


 //不需要让外部知道,写在实现文件就可以

 -(instancetype)initWithIcon:(NSString *)icon title:(NSString *)title subTitle:(NSString *)subTitle

 {

     if (self == [super init]) {

         self.icon = icon;

         self.title = title;

         self.subTitle = subTitle;

     }

     return self;

 }

 +(instancetype)cellWithIcon:(NSString *)icon title:(NSString *)title

 {

     return [[self alloc] initWithIcon:icon title:title subTitle:nil];

 }

 +(instancetype)cellWithTitle:(NSString *)title subTitle:(NSString *)subTitle

 {

     return [[self alloc] initWithIcon:nil title:title subTitle:subTitle];

 }

/******************* ****************************&************ *******************************************/

block使用精髓:自定义block实现传值

// block:作用保存一段代码

#pragma mark - XMGPopMenuDelegate

 // 点击菜单上关闭按钮的时候就会调用

 - (void)popMenuDidClickCloseMenu:(XMGPopMenu *)menu

 {

     // 定义移动完成的block,保存移动完成的代码

     void (^completion)() = ^{

         // 当移动完成的时候,把蒙板消失

         [XMGCover hide];

     };

     // block精髓:可以当做参数去用。

     // 菜单移动到某个位置,并且缩放。

     [menu hideInPoint:CGPointMake(, ) completion:completion];

 }

// 隐藏到某个点

  • //- (void)hideInPoint:(CGPoint)point completion:(参数类型)参数变量名;
  • // completion:隐藏完成的时候执行的代码
  • - (void)hideInPoint:(CGPoint)point completion:(void(^)())completion;
 // 隐藏

 - (void)hideInPoint:(CGPoint)point completion:(void (^)())completion

 {

     [UIView animateWithDuration:. animations:^{

         self.center = point;

         // 直接修改父控件的尺寸,是不会影响子控件

         //        self.bounds = CGRectMake(0, 0, 1, 1);

         // 如果设置0,控件直接缩放为0,没有动画,如果想要动画,搞一个最小值

         self.transform = CGAffineTransformMakeScale(0.01, 0.01);

     } completion:^(BOOL finished) {

         [self removeFromSuperview];

         if (completion) {

             completion();

         }

             /*

      void (^completion)() = ^{

      // 当移动完成的时候,把蒙板消失

      [XMGCover hide];

      };

      */

         // 移除蒙板

         //        [XMGCover hide];

     }];

 }

/***************** *******************&.使用拼接方式实现tabBar按钮图片的设置(解藕)********************************************/

1):定义前缀,后缀和图片数组

 /**

  *  图片的前缀

  */

 @property (nonatomic, copy) NSString *prefix;

 /**

  *  图片选中的后缀

  */

 @property (nonatomic, copy) NSString *seleSubfix;

 /**

  *  设置各个按钮正常状态的背景图片

  */

 @property (nonatomic, strong) NSArray *normalImgs;

2):在数组的setter方法中遍历图片数组,创建对应的按钮,并且根据是否有前缀和后缀(选中)设置对应的图片

 //判断是否有前缀

 NSString *normal = img;

 if (self.prefix) {

     normal = [NSString stringWithFormat:@"%@%@", self.prefix, img];

 }

 [tabBarBtn setBackgroundImage:[UIImage imageNamed:normal] forState:UIControlStateNormal];

 //判断是否有后缀

 if (self.seleSubfix) {

     NSString *selectedImage = [normal stringByAppendingString:self.seleSubfix];

     [tabBarBtn setBackgroundImage:[UIImage imageNamed:selectedImage] forState:UIControlStateSelected];

 } else {

     NSLog(@"iCocos 没有设置后缀图片");

 }

3):使用的时候,创建对应的控件,然后创建一个图片中间名字的数组,设置对应的前缀和后缀,最后将中间名字的数组赋值给前面的图片数组属性

/**

*  设置tabBar默认图片和选中的图片——》这里使用的是拼接技术,由于图片不是连贯的

*/

 NSArray *imgs = @[@"LotteryHall",@"Arena",@"Discovery",@"History",@"MyLottery"];

 //设置前缀和选中的图片

 tabBar.prefix = @"TabBar_";

 tabBar.seleSubfix = @"_selected";

 //设置图片数组为tabBar中的数组图片

 tabBar.normalImgs = imgs;

iOS开发——实战总结OC篇&网易彩票开发知识点总结的更多相关文章

  1. asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发4- 后台模板html页面创建

    上一篇教程<asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发3-登录模块开发>完成了本项目的登录模块,登录后就需要进入后台管理首页了,需要准备一个后台模 ...

  2. asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发2-Model层建立

    上篇(asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发1-准备工作)文章讲解了开发过程中的准备工作,主要创建了项目数据库及项目,本文主要讲解项目M层的实现,M层这里 ...

  3. ios开发——实用技术篇OC篇&iOS的主要框架

    iOS的主要框架         阅读目录 Foundation框架为所有的应用程序提供基本系统服务 UIKit框架提供创建基于触摸用户界面的类 Core Data框架管着理应用程序数据模型 Core ...

  4. 大数据开发实战:Spark Streaming流计算开发

    1.背景介绍 Storm以及离线数据平台的MapReduce和Hive构成了Hadoop生态对实时和离线数据处理的一套完整处理解决方案.除了此套解决方案之外,还有一种非常流行的而且完整的离线和 实时数 ...

  5. iOS开发——网络实用技术OC篇&网络爬虫-使用青花瓷抓取网络数据

    网络爬虫-使用青花瓷抓取网络数据 由于最近在研究网络爬虫相关技术,刚好看到一篇的的搬了过来! 望谅解..... 写本文的契机主要是前段时间有次用青花瓷抓包有一步忘了,在网上查了半天也没找到写的完整的教 ...

  6. iOS开发——高级技术OC篇&运行时(Runtime)机制

    运行时(Runtime)机制 本文将会以笔者个人的小小研究为例总结一下关于iOS开发中运行时的使用和常用方法的介绍,关于跟多运行时相关技术请查看笔者之前写的运行时高级用法及相关语法或者查看响应官方文档 ...

  7. iOS开发——网络实用技术OC篇&网络爬虫-使用java语言抓取网络数据

    网络爬虫-使用java语言抓取网络数据 前提:熟悉java语法(能看懂就行) 准备阶段:从网页中获取html代码 实战阶段:将对应的html代码使用java语言解析出来,最后保存到plist文件 上一 ...

  8. iOS开发——UI精选OC篇&UIApplication,UIWindow,UIViewController,UIView(layer)简单介绍

    UIApplication,UIWindow,UIViewController,UIView(layer)简单介绍 一:UIApplication:单例(关于单例后面的文章中会详细介绍,你现在只要知道 ...

  9. iOS开发——运行时OC篇&使用运行时获取系统的属性:使用自己的手势修改系统自带的手势

    使用运行时获取系统的属性:使用自己的手势修改系统自带的手势 有的时候我需要实现一个功能,但是没有想到很好的方法或者想到了方法只是那个方法实现起来太麻烦,一或者确实为了装逼,我们就会想到iOS开发中最牛 ...

随机推荐

  1. Request、Request.Form、Request.QueryString 用法的区别

    Request.Form:获取以POST方式提交的数据. Request.QueryString:获取地址栏参数(以GET方式提交的数据). Request:包含以上两种方式(优先获取GET方式提交的 ...

  2. nodejs 调用 OC 方法

    nodejs 借助 nodobjc 模块 https://github.com/TooTallNate/NodObjC demo: var $ = require('nodobjc') $.frame ...

  3. Latex 横排图片

    \begin{figure} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in]{figure/an ...

  4. CSRF的攻击与防御(转)

    add by zhj:CSRF之所有发生,是因为http请求中会自动带上cookies,我的解决办法是:前端不要将数据放在cookie中,而是放在其它本地存储 (HTML5中称之为Web Storag ...

  5. JVM系列四:生产环境参数实例及分析【生产环境实例增加中】

    java application项目(非web项目) 改进前: -Xms128m-Xmx128m-XX:NewSize=64m-XX:PermSize=64m-XX:+UseConcMarkSweep ...

  6. Socket小项目的一些心得(鸣谢传智的教学视频)

    Socket是一种封装了四层通信的整体抽象入口,通常也称作"套接字",这是常用的四层通信这是访问Socket的流程图,这个分为客户端和服务器端,其中服务器端有以下步骤去建立,前面的 ...

  7. HTTP原理

    HTTP原理 1 简介 HTTP是一个属于应用层的面向对象的协议,由于其简捷.快速的方式,适用于分布式超媒体信息系统. HTTP协议的主要特点可概括如下: 1.支持客户/服务器模式. 2.简单快速:客 ...

  8. Lucene/ElasticSearch 学习系列 (1) 为什么学,学什么,怎么学

    为什么学 <What I wish I knew When I was 20>这本书给了我很多启发.作者在书中提到,Stanford 大学培养人才的目标是 ”T形人才“:精通某个领域,但对 ...

  9. 访问ControlTemplate内部的元素

    需要用到code behind 注意要给需要访问的元素命名x:Name="PART_TextBlock" <ResourceDictionary xmlns="ht ...

  10. 传统的Ado.net 参数设置:params SqlParameter[] commandParameters

    C#代码  ExecuteReader(string connectionString, CommandType commandType, string commandText, params Sql ...