iOS开发——实战总结OC篇&网易彩票开发知识点总结
网易彩票开发知识点总结
关于网易彩票开发中遇到了不少的坑,弄了好久才弄懂,或者有些犹豫很久没用就不记得了,所以这里就总结了一下,希望以后不会忘记,就算忘记也能快速查看!
/***************************************&.设置状态栏样式(白色) 两种方法******************************************/
-(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篇&网易彩票开发知识点总结的更多相关文章
- asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发4- 后台模板html页面创建
上一篇教程<asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发3-登录模块开发>完成了本项目的登录模块,登录后就需要进入后台管理首页了,需要准备一个后台模 ...
- asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发2-Model层建立
上篇(asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发1-准备工作)文章讲解了开发过程中的准备工作,主要创建了项目数据库及项目,本文主要讲解项目M层的实现,M层这里 ...
- ios开发——实用技术篇OC篇&iOS的主要框架
iOS的主要框架 阅读目录 Foundation框架为所有的应用程序提供基本系统服务 UIKit框架提供创建基于触摸用户界面的类 Core Data框架管着理应用程序数据模型 Core ...
- 大数据开发实战:Spark Streaming流计算开发
1.背景介绍 Storm以及离线数据平台的MapReduce和Hive构成了Hadoop生态对实时和离线数据处理的一套完整处理解决方案.除了此套解决方案之外,还有一种非常流行的而且完整的离线和 实时数 ...
- iOS开发——网络实用技术OC篇&网络爬虫-使用青花瓷抓取网络数据
网络爬虫-使用青花瓷抓取网络数据 由于最近在研究网络爬虫相关技术,刚好看到一篇的的搬了过来! 望谅解..... 写本文的契机主要是前段时间有次用青花瓷抓包有一步忘了,在网上查了半天也没找到写的完整的教 ...
- iOS开发——高级技术OC篇&运行时(Runtime)机制
运行时(Runtime)机制 本文将会以笔者个人的小小研究为例总结一下关于iOS开发中运行时的使用和常用方法的介绍,关于跟多运行时相关技术请查看笔者之前写的运行时高级用法及相关语法或者查看响应官方文档 ...
- iOS开发——网络实用技术OC篇&网络爬虫-使用java语言抓取网络数据
网络爬虫-使用java语言抓取网络数据 前提:熟悉java语法(能看懂就行) 准备阶段:从网页中获取html代码 实战阶段:将对应的html代码使用java语言解析出来,最后保存到plist文件 上一 ...
- iOS开发——UI精选OC篇&UIApplication,UIWindow,UIViewController,UIView(layer)简单介绍
UIApplication,UIWindow,UIViewController,UIView(layer)简单介绍 一:UIApplication:单例(关于单例后面的文章中会详细介绍,你现在只要知道 ...
- iOS开发——运行时OC篇&使用运行时获取系统的属性:使用自己的手势修改系统自带的手势
使用运行时获取系统的属性:使用自己的手势修改系统自带的手势 有的时候我需要实现一个功能,但是没有想到很好的方法或者想到了方法只是那个方法实现起来太麻烦,一或者确实为了装逼,我们就会想到iOS开发中最牛 ...
随机推荐
- layout相关
大致看了看布局大致有5种(approximately) 1. LinearLayout 2. RelativeLayout 3. FrameLayout 4. TableLayout 5. GridL ...
- 如何杀掉当前正在执行的hadoop任务
[root@Slave01 ~]# hadoop job -listDEPRECATED: Use of this script to execute mapred command is deprec ...
- webrtc--AudioProcessing的使用
1.AudioProcessing的实例化和配置: AudioProcessing* apm = AudioProcessing::Create(0); apm->level_estimator ...
- 从今天开始每天刷一题,并写在这里 分类: ACM 2015-06-16 23:52 14人阅读 评论(0) 收藏
开始什么题都可以,后面会加大难度. 每天! 如果有一天有特殊情况,也要来这里打卡,并说明原因,并在其他某一天补上! 版权声明:本文为博主原创文章,未经博主允许不得转载.
- Physicals
[Physicals] The physics simulation in Sprite Kit is performed by adding physics bodies to scenes. [T ...
- CodeForces 702B Powers of Two (暴力,优化)
题意:给定 n 个数,问你从有多少下标 i < j,并且 ai + aj 是2的倍数. 析:方法一: 从输入开始暴力,因为 i < j 和 i > j 是一样,所以可以从前面就开始查 ...
- centos下 Apache、php、mysql默认安装路径
centos下 Apache.php.mysql默认安装路径 http://blog.sina.com.cn/s/blog_4b8481f70100ujtp.html apache: 如果采用RPM包 ...
- STM32 + RT Thread OS 学习笔记[三]
RTGUI 据说RTGUI是多线程的,因此与RT-Thread OS的耦合度较高,有可能要访问RT-Thread的线程控制块.如果要移植到其它OS,估计难度较大.目前还处于Alpha状态,最终将会包含 ...
- LVS 单独完成--负载均衡
原文地址:http://blog.sina.com.cn/s/blog_5f54f0be0101eyiu.html LVS 是通过 IPVS 模块来实现的.IPVS是LVS集群的核心,主要用于完成用户 ...
- 常用CSS3效果:用text-shadow做CSS3 文字描边
思路: 利用CSS3的text-shadow属性,对文字的四个边均用阴影. 最终效果: 单纯的为了实现效果.未作任何美化. 实现代码: HTML: <div>文字描边效果</div& ...