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. (6) 深入理解Java Class文件格式(五)

    前情回顾 本专栏的前几篇博文, 对class文件中的常量池进行了详细的解释. 前文讲解了常量池中的7种数据项, 它们分别是: CONSTANT_Utf8_info CONSTANT_NameAndTy ...

  2. Android Fragment 真正的完全解析(上)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/37970961 自从Fragment出现,曾经有段时间,感觉大家谈什么都能跟Fra ...

  3. selenium杀掉浏览器进程方法

    * 杀掉浏览器进程      */     public static void operateWindowsProcess(){         WindowsUtils.tryToKillByNa ...

  4. Java线程锁一个简单Lock

    /** * @author * * Lock 是java.util.concurrent.locks下提供的java线程锁,作用跟synchronized类似, * 单是比它更加面向对象,两个线程执行 ...

  5. ucenter的单点登录

    所谓单点登录,无非就是几个站点共用一个用户中心,实现同步登陆,同步退出. 服务器端:Loog SSO . 客服端: ucenter,说实话dz商业化确实让php发展了不少. ucenter 基本原理: ...

  6. minicom 使用教程

    因为现在电脑基本不配备串行接口,所以,usb转串口成为硬件调试时的必然选择.目前知道的,PL2303的驱动是有的,在dev下的名称是ttyUSB#. minicom,tkterm都是linux下应用比 ...

  7. 使用exec命令删除前几天产生的日志

    上次学习了访问某个网站并产生相应的日志保存在指定位置,但是时间长了,日志会占用磁盘大量的空间,下面使用exec这个命令删除之前的日志: 命令格式: find 目录绝对路径 -mtime +n(时间) ...

  8. python time模块

    time模块 (有效时间1970-2038) (1)本地时间 (2)时间戳 (3)延时 time.localtime([secs]) #struct_time time.time() #timesta ...

  9. 学习c++

    慢慢的滑向无边无际的没有回头路的程序猿道路.坚持就是胜利. 致渣渣

  10. hosts代理

    hosts代理文件:C:\Windows\System32\drivers\etc\HOSTS 内容如下: # Copyright (c) -, racaljk. # https://github.c ...