1.NSlog  发布后不打印

#ifdef DEBUG// 如果有DEBUG这个宏就编译下面一句代码

#define DDLog(...) NSLog(__VA_ARGS__)

#else // 如果没有DEBUG这个宏就编译下面一句代码

#define DDLog(...)

#endif

2.三方库及其他整理

用过的三方库:

1.​AFNetworking   HTTP 网络请求库  

2.​SDWebImage 图片缓存

3.​MBProgressHUD 加载中展示

4.MMDrawerController​ 抽屉视图(自己也可以模仿再重写)​

5.​FMDB  sqlite

6.MJRefresh​   tableview 下拉刷新上拉加载

7.WebViewJavascriptBridge​ 实现OC与JS交互

8.SBJSON​   json解析

9.MJExtension​    模型转换

10.SVPullToRefresh​  scrollview 上加下拉刷新

11.​Masonry/SnapKit     自适应布局 (类安卓的相对布局,由于本人1年安卓2年iOS 用起来挺顺手)

12.​AFPopupView  实现炫酷的跳转

13.​AwesomeMenu 实现炫酷工具栏效果

14.MJPhotoBrowser​   实现图片浏览效果,有个导致crash的bug,之后会更

15.  ZXingObjC   二维码 

16.MKNetworkKit​ 轻量级HTTP 网络请求库

17.jpush   推送

18.alipay  支付宝支付

19.微信支付

20.友盟  分享、三方登陆、推送、数据记录、crash记录

21.iCarousel​  实现Coverflow效果。

22.SDCycleScrollView  无限轮播器

没有过的:

1.JSPatch js脚本更新线上代码(应急用)

2.CocoaPod​ 三方库的管理工具

3.更新Xcode后,三方插件不能用的解决方法

1.在终端中输入  defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID 会得到一串码即本版本xocde的UUID,复制留用。

2.前往文件夹~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/

这个插件目录是所谓的插件目录,找到相应的插件,右击显示报内容,打开里面的info.plist,找到DVTPlugInCompatibilityUUIDs 字段,将操作 1 中得到的UUID 添加到此处即可。重启xcode就可以使用了

4.获取带毫秒的NSDate

NSDateFormatter *dateFormatter = [[NSDateFormatteralloc] init];

[dateFormatter setDateStyle:NSDateFormatterMediumStyle];

[dateFormatter setTimeStyle:NSDateFormatterShortStyle];

//[dateFormatter setDateFormat:@"hh:mm:ss"]

[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];

NSLog(@"-------0Date%@", [dateFormatter stringFromDate:[NSDate date]]);

5.WebViewJavascriptBridge的使用

转载2015-07-07 16:21:25

1.初始化一个webview(viewdidload)

@property (nonatomic, strong) WebViewJavascriptBridge *mainbridge;

UIWebView* webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:webView];
 2.将此webview与WebViewJavascriptBridge关联(viewdidload)     [WebViewJavascriptBridgeenableLogging];
self.mainbridge = [WebViewJavascriptBridgebridgeForWebView:weakSelf webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)weakSelf.delegatehandler:^(id data, WVJBResponseCallback responseCallback) {
根据data 就可以判断了​
      }
 (3)oc给js传值(通过 response接受返回值 )  
[mainbridge send:@"A string sent from ObjC before Webview has loaded."responseCallback:^(id responseData) {
        NSLog(@"objc got response! %@", responseData);
    }];

6.swift 中AnyObject 转string 转 array

从json数组取得AnyObject  类型的anyData

var anyData: AnyObject! = resultDic.objectForKey("wxts1")

转string

var Datatext: String! = String(stringInterpolationSegment: anyData)

转array

1.        let DataArray: AnyObject! = anyData​

2.           var DataArray:NSArray = (anyData as! NSArray) asArray​

7.在swift中使用oc库

只要用到的是个.h  文件

1.先创建一个.h文件,可命名为Bridging-Header.​h

2.​在build setting 中找到Object-C Bridging Header 中添加Bridging-Header.​h 的相对路径

3.在​Bridging-Header.​h 中引入锁需的三方库或者oc类   如:#import"AFNetworking.h"

8.NSString 打印为(null),为空判断

NSString* remain_delivery_day = [resultDic objectForKey:@"remain_delivery_day"]

服务器返回为空的话​​remain_delivery_day便会输出(null),

发现​​remain_delivery_day isKindOfClass:[NSNull class]、[remain_delivery_day isEqualToString:@"(null)"] 都不可判断其为空,==nil也不行

解决方案最常用的是​remain_delivery_day length]==0

还有[remain_delivery_day isEqual:[NSNullnull]] ​

其实明白:​nil是一个对象指针为空,Nil是一个类指针为空,NULL是基本数据类型为空。区别就是nil是一个对象,而NULL只是一个值   看这个问题就不是那么难了

9.放大一个imageview

#define CONST_animation_time 0.5

#define CONST_enlarge_proportion 15.0

CGPoint UpPointOfView(UIView *view)

{

return (CGPoint){view.center.x, 200+2+55/2};

};

- (void) circleAnimate:(UIImageView*)view

{

CGContextRef context = UIGraphicsGetCurrentContext();

[UIView beginAnimations:nil context:context];

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationDuration:CONST_animation_time];

[view setCenter:UpPointOfView(view)];

CABasicAnimation *scalingAnimation = (CABasicAnimation *)[view.layer animationForKey:@"scaling"];

if (!scalingAnimation)

{

scalingAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];

scalingAnimation.repeatCount=1;

scalingAnimation.duration=CONST_animation_time;

scalingAnimation.autoreverses=NO;

scalingAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

scalingAnimation.fromValue=[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)];

scalingAnimation.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeScale(CONST_enlarge_proportion,CONST_enlarge_proportion, 1.0)];

}

[view.layer addAnimation:scalingAnimation forKey:@"scaling"];

view.layer.transform = CATransform3DMakeScale(CONST_enlarge_proportion,CONST_enlarge_proportion, 1.0);

[UIView commitAnimations];

}

10.利用手势给图片添加点击事件

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(imageviewclick)];

[imageview addGestureRecognizer:singleTap];//点击图片事件,

imageview.userInteractionEnabled = YES;

11.iOS伪表单上传图片

- (void) imageUpload:(UIImage *) image{

//把图片转换成imageDate格式

NSData *imageData = UIImageJPEGRepresentation(image, 0.5);

//传送路径

NSString *urlString = @"http://www.呃呃呃呃呃.com/ImageUpload/uploadImg";

//建立请求对象

NSMutableURLRequest * request = [[NSMutableURLRequestalloc] init];

//设置请求路径

[request setURL:[NSURLURLWithString:urlString]];

//请求方式

[request setHTTPMethod:@"POST"];

//一连串上传头标签

NSString *boundary = (NSString*)@"---------------------------14737809831466499882746641449";

NSString *contentType = [NSStringstringWithFormat:@"multipart/form-data; boundary=%@",boundary];

[request addValue:contentType forHTTPHeaderField: @"Content-Type"];

NSMutableData *body = [NSMutableDatadata];

[body appendData:[[NSStringstringWithFormat:@"\r\n--%@\r\n",boundary]dataUsingEncoding:NSUTF8StringEncoding]];

[body appendData:[@"Content-Disposition: form-data; name=\"upfile\"; filename=\"bb\"\r\n"dataUsingEncoding:NSUTF8StringEncoding]];

[body appendData:[@"Content-Type: application/octet-stream\r\n\r\n"dataUsingEncoding:NSUTF8StringEncoding]];

[body appendData:[NSDatadataWithData:imageData]];

[body appendData:[[NSStringstringWithFormat:@"\r\n--%@--\r\n",boundary]dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:body];

//上传文件开始

//+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse **)response error:(NSError **)error;

NSData *returnData = [NSURLConnectionsendSynchronousRequest:requestreturningResponse:nilerror:nil];

//获得返回值

NSString *returnString = [[NSStringalloc] initWithData:returnDataencoding:NSUTF8StringEncoding];

NSData *data = [returnString dataUsingEncoding:NSUTF8StringEncoding];

NSDictionary *resultDic = [NSJSONSerializationJSONObjectWithData:dataoptions:NSJSONReadingMutableLeaveserror:nil];

//    NSLog(@"%@",resultDic);

NSString * str11 = [NSStringstringWithFormat:@",%@",[resultDicobjectForKey:@"img_url"]];

[urlImageHeadappendString:str11];

}

12.iOS简单post

NSString *postString = [NSStringstringWithFormat:@"         {\\"userName\\":\\"%@\\",\\"userPass\\":\\"%@\\",\\"version\\":\\"1.0\\"}",self.userField.text,self.passwordField.text];

NSLog(@"%@",postString);

//一般转化称UTF-8,这里服务器需要ASCII

NSData* postData = [postStringdataUsingEncoding:NSASCIIStringEncodingallowLossyConversion:YES];

NSMutableURLRequest *request = [[[NSMutableURLRequestalloc] init] autorelease];

[requestsetURL:[NSURLURLWithString:@"http://lib.wap.zol.com.cn/test/login.php"]];

[requestsetCachePolicy:NSURLRequestUseProtocolCachePolicy];

[requestsetTimeoutInterval:100.0];

[request setHTTPMethod:@"POST"];

[request setHTTPBody:postData];

// 应该是application/x-www-form-urlencoded,但对方服务器写成了appliction/x-www-form-urlencoded,告诉服务器是一个表单提交数据方式

[requestsetValue:@"appliction/x-www-form-urlencoded"forHTTPHeaderField:@"Content-Type"];

//得到提交数据的长度

NSString* len = [NSString stringWithFormat:@"%d", [postData length]];

//添加一个http包头告诉服务器数据长度是多少

[requestsetValue:len forHTTPHeaderField:@"Content-Length"];

[NSURLConnectionconnectionWithRequest:request delegate:self];

13.iOS原生json解析

NSData *jsonData = [[NSData alloc] initWithContentsOfFile:JSON_PATH];

NSError *error = nil;

id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:&error;];

if (jsonObject != nil && error == nil){

NSLog(@"Successfully deserialized...");

if ([jsonObject isKindOfClass:[NSDictionary class]]){

NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;

NSLog(@"Dersialized JSON Dictionary = %@", deserializedDictionary);

} elseif ([jsonObject isKindOfClass:[NSArray class]]){

NSArray *deserializedArray = (NSArray *)jsonObject;

NSLog(@"Dersialized JSON Array = %@", deserializedArray);

} else {

NSLog(@"An error happened while deserializing the JSON data.");

}

}

14.模仿MBProgressHUD 成功

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil

message:[@"Alert"

delegate:nil

cancelButtonTitle:nil//NSLocalizedString(@"OK", @"OK")   //

otherButtonTitles:nil];

//[alert setBounds:CGRectMake(alert.bounds.origin.x, alert.bounds.origin.y, alert.bounds.size.width, alert.bounds.size.height+30.0)];

[alert show];

UIActivityIndicatorView *indicator = [[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

// Adjust the indicator so it is up a few pixels from the bottom of the alert

indicator.center = CGPointMake(alert.bounds.size.width/2,  alert.bounds.size.height-40.0);

[indicator startAnimating];

[alert insertSubview:indicator atIndex:0];

[indicator release];

[NSTimer scheduledTimerWithTimeInterval:3.0f

target:self

selector:@selector(dismissAlert:)

userInfo:[NSDictionary dictionaryWithObjectsAndKeys:alert, @"alert", @"testing ", @"key" ,nil]  //nil.

repeats:NO];

NSLog(@"release alert");

[alert release];

-(void) dismissAlert:(NSTimer *)timer{

NSLog(@"release timer");

NSLog([[timer userInfo] objectForKey:@"key"]);

UIAlertView* alert = [[timer userInfo] objectForKey:@"alert"];

[alert dismissWithClickeonIndex:0 animated:YES];

}

//

[timer invalidate];

timer = nil;

15.UITableView   滑动到某一行

创建NSIndexPath

NSIndexPath*scrollIndexPath =[NSIndexPath indexPathForRow:10 inSection:0];

自己的tableview开始滚动​

​[[self tableView] scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];

16.常用小代码

[[[UIApplication sharedApplication] keyWindow] endEditing:YES];//关闭键盘

取消cell的选中状态cell.selectionStyle = UITableViewCellSelectionStyleNone;

状态栏          [[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleDefault];

self.navigationController.navigationBarHidden = yes;​隐藏引导栏

17.关于Unbalanced calls to begin/end appearance transitions for

在自定义的tabbarvc里添加

- (void)viewWillAppear:(BOOL)animated

{

[self.selectedViewController beginAppearanceTransition: YES animated: animated];

}

-(void) viewDidAppear:(BOOL)animated

{

[self.selectedViewController endAppearanceTransition];

}

-(void) viewWillDisappear:(BOOL)animated

{

[self.selectedViewController beginAppearanceTransition: NO animated: animated];

}

-(void) viewDidDisappear:(BOOL)animated

{

[self.selectedViewController endAppearanceTransition];

}

18.CUICatalog: Invalid asset name supplied: (null)

[UIImage imageNamed:name];但是这个name却是空的,所以就报了这个错了。

解决方法,在项目中搜索[UIImage imageNamed:,然后打印看看所谓的name是否为空。找到后替换

ios 各种技术的更多相关文章

  1. iOS多线程技术方案

    iOS多线程技术方案 目录 一.多线程简介 1.多线程的由来 2.耗时操作的模拟试验 3.进程和线程 4.多线程的概念及原理 5.多线程的优缺点和一个Tip 6.主线程 7.技术方案 二.Pthrea ...

  2. 【腾讯Bugly干货分享】iOS黑客技术大揭秘

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/5791da152168f2690e72daa4 “8小时内拼工作,8小时外拼成长 ...

  3. ios面试技术要点

    iOS面试 技术总结点(可参考):多线程 运行时 runloop app框架 几种动画编程 jsonmodel原理 sdwebimage原理 masonry怎么应用及原理 应用框架有哪些 说一下Fac ...

  4. iOS多线程技术

    iOS多线程技术主要分配NSThread.NSOperation和GCD.下边来简单的介绍一下吧. 随性一点,就不按照顺序来了.所以先介绍一下NSOperation. ---------------- ...

  5. iOS开发技术分享(1)— iOS本地数据存储

    iOS开发技术分享(1)— iOS本地数据存储 前言: 我本是一名asp.net程序员,后来加入了iOS游戏开发队伍,到现在也有一年多的时间了.这一年来,每天都干到2.3点钟才睡觉,不为别的,只为了学 ...

  6. fir.im Weekly - 8 个不能错过的 iOS / Android 技术分享

    本期 fir.im Weekly 收集了 2 月下旬新鲜出炉的 iOS /Android 技术分享.源码等,iOS 中图片技术的解压缩.逆向实战.iOS SDK 实践,Android架构思考.Andr ...

  7. 了解iOS消息推送一文就够:史上最全iOS Push技术详解

    本文作者:陈裕发, 腾讯系统测试工程师,由腾讯WeTest整理发表. 1.引言 开发iOS系统中的Push推送,通常有以下3种情况: 1)在线Push:比如QQ.微信等IM界面处于前台时,聊天消息和指 ...

  8. iOS 开发技术体系

    iOS 开发技术体系图: - 层级 | 主要框架 - ---------------------|--------------------------------------------------- ...

  9. 转: HTTP Live Streaming直播(iOS直播)技术分析与实现

    http://www.cnblogs.com/haibindev/archive/2013/01/30/2880764.html HTTP Live Streaming直播(iOS直播)技术分析与实现 ...

  10. iOS 多线程技术2

    iOS 多线程技术2 NSOperation NSInvocationOperation //创建一个队列 NSOperationQueue *queue = [[NSOperationQueue a ...

随机推荐

  1. Zabbix安装图解教程

    说明: 操作系统:CentOS IP地址:192.168.21.127 Web环境:Nginx+MySQL+PHP zabbix版本:Zabbix 2.2 LTS 备注:Linux下安装zabbix需 ...

  2. C++ string到底是什么

    C++ string到底是什么? 要回答这个问题,先要了解什么是basic_string.看一下basic_string的声明: template < class charT, //定义字符串中 ...

  3. Maven学习(五)-- 聚合与继承

    标签(空格分隔): 学习笔记 Maven的聚合特性能够把项目的各个模块聚合在一起构建: Maven的继承特性能够帮助抽取各模块相同的依赖和插件等配置,在简化POM的同时,还能够促进各个模块配置的一致性 ...

  4. 堆排序(C++实现)

    #include<iostream> #include<vector> using namespace std; void swap(vector<int> &am ...

  5. 《BI项目笔记》创建父子维度

    创建步骤: 而ParentOriginID其实就是对应的ParentOriginID,它的 Usage 必须是 Parent 才能表示这样的一个父子维度. 查看OriginID属性, Usage 是 ...

  6. LTE Module User Documentation(翻译15)——示例程序、参考场景以及故障检测和调试技巧

    LTE用户文档 (如有不当的地方,欢迎指正!)     21 Examples Programs(示例程序)   路径 src/lte/examples/ 包含一些示例仿真程序,这些例子表明如何仿真不 ...

  7. OllyDBG 1.10

    OllyDBG 1.10 OllyDBG.exeOllyDBG SoftICE文件->打开 (快捷键是 F3)F2 断点 F9F8 步过 F10F7 步入 F8F4 运行到位置 F7F9 运行 ...

  8. phpstormn 中 xdebug 的详细配置2

    配置PHPStorm 图1:首先配置PHP解释器的路径 图2:File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填localhost,host ...

  9. loading

    <!doctype html> <html> <head> <title>实惠福利</title> <meta charset=&qu ...

  10. MySQL 句柄数占用过多的解决方法

    在Windows下安装MySQL ,用了官方的配置向导生成了my.ini,本以为很安稳了,谁知十多个小时过去之后,系统响应非常慢,看资源管理器的性能卡,发现句柄数竟然达到了10万!怪不得无论使用什么程 ...