IOS开发基础知识--碎片51
1:https关闭证书跟域名的验证
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy defaultPolicy];
securityPolicy.allowInvalidCertificates = YES;
securityPolicy.validatesDomainName = NO;
_manager.securityPolicy = securityPolicy;
如果报 In order to validate a domain name for self signed certificates, you MUST use pinning 也是上面这种方式进行解决
2: iOS UIWebView 访问https绕过证书验证的方法
@implementation NSURLRequest (NSURLRequestWithIgnoreSSL)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES;
}
@end
3:SDWebImage加载图片绕过证书
[myImageView sd_setImageWithURL:[NSURL URLWithString:replyModel.reply_name] placeholderImage:[UIImage imageNamed:@"default_header"] options:SDWebImageAllowInvalidSSLCertificates]
4:关于Https一些不错的文章介绍
http://oncenote.com/2014/10/21/Security-1-HTTPS/
http://www.jianshu.com/p/2d72ef8dbf5a
http://www.jianshu.com/p/b03ae4a1a2d3
https://github.com/cos6meteors/YMHttpsTest
http://blog.csdn.net/duanbokan/article/details/50847612
http://www.cocoachina.com/ios/20161220/18393.html
5:强制去除HTML标签的文本
+ (NSString *)getStandarString:(NSString *)str
{ NSArray *components = [str componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
NSMutableArray *componentsToKeep = [NSMutableArray array]; for (int i = ; i < [components count]; i = i + ) { NSString *str = [components objectAtIndex:i];
if (str.length) {
[componentsToKeep addObject:[components objectAtIndex:i]];
} } NSString *plainText = [componentsToKeep componentsJoinedByString:@"\n"]; plainText = [[[plainText description]stringByReplacingOccurrencesOfString:@" " withString:@""]stringByReplacingOccurrencesOfString:@" " withString:@""]; return plainText; }
6: iOS8以后第三方键盘,获取高度为0的问题
IOS8.0之后可以安装第三方键盘,如搜狗输入法之类的。
获得的高度都为0.这是因为键盘弹出的方法:- (void)keyBoardWillShow:(NSNotification *)notification需要执行三次,你如果打印一下,你会发现键盘高度为:第一次:0;第二次:216:第三次:282.并不是获取不到高度,而是第三次才获取真正的高度.
可以在UIKeyboardDidChangeFrameNotification的通知中实现,这里需要注意的是:在弹出键盘时该方法执行3次,需要进行处理,已达到所要的效果.
注册键盘事件:
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyBoardChange:) name:UIKeyboardDidChangeFrameNotification object:nil];
pragma mark–键盘改变事件的触发
(void)keyBoardChange:(NSNotification *)notification{
NSDictionary *dict = notification.userInfo;
NSValue *aValue = [dict objectForKey:UIKeyboardFrameEndUserInfoKey];
NSNumber *animationTime = [dict objectForKey:@”UIKeyboardAnimationDurationUserInfoKey”];
CGRect keyboardRect = [aValue CGRectValue];
CGFloat keyHeight = (HEIGHT(self.view)-Y(searBar)-HEIGHT(searBar))-keyboardRect.size.height;
if(keyHeight<=){
[UIView animateWithDuration:[animationTime doubleValue] animations:^{
self.view.frame =CGRectMake(, keyHeight, WIDTH(self.view), HEIGHT(self.view));
} completion:^(BOOL finished) {
}];
}
}
pragma mark–键盘隐藏事件
(void)keyBoardDidHide:(NSNotification *)notification{
self.view.frame = CGRectMake(, , WIDTH(self.view), HEIGHT(self.view));
}
另有一份代码:
- (void)keyboardWillShow:(NSNotification *)notification {
CGFloat curkeyBoardHeight = [[[notification userInfo] objectForKey:@"UIKeyboardBoundsUserInfoKey"] CGRectValue].size.height;
CGRect begin = [[[notification userInfo] objectForKey:@"UIKeyboardFrameBeginUserInfoKey"] CGRectValue];
CGRect end = [[[notification userInfo] objectForKey:@"UIKeyboardFrameEndUserInfoKey"] CGRectValue];
// 第三方键盘回调三次问题,监听仅执行最后一次
if(begin.size.height> && (begin.origin.y-end.origin.y>)){
keyBoardHeight = curkeyBoardHeight;
[self showKeyboard:notification];
}
}
7:UITableView-FDTemplateLayoutCell在IOS10.3中的兼容问题
10.3 系统,Label高度自适应不行了
在cell里进行布局之前先对contentView进行约束就可以了,解决的方式如下:
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self); }];
8: jenkins打包问题
自动打包时一直报:
error: Resource "/Users/jenkins/Library/Developer/Xcode/DerivedData/zxptUser-ekdrtnqmfkdbvqdhibtuhmrvdzhj/Build/Products/Debug-iphoneos/MWPhotoBrowser/MWPhotoBrowser.bundle" not found. Run 'pod install' to update the copy resources script.
解决办法:
https://github.com/CocoaPods/CocoaPods/issues/5358
如上所说:
in my case, in Jenkins config:
- SYMROOT must be set
- BUILD_DIR has no incidence
- CONFIGURATION_BUILD_DIR must not be set
而在我们自动打包的脚本中有一处:
build()
{
echo "`date` start to build project..."
cd $WorkSpace
/usr/local/bin/xctool -workspace Blossom.xcworkspace -scheme Blossom_test CONFIGURATION_BUILD_DIR=$CompileOutputPath #PROVISIONING_PROFILE=$ProvisioningProfile }
问题所在地方就是:CONFIGURATION_BUILD_DIR
build()
{
echo "`date` start to build project..."
cd $WorkSpace
/usr/local/bin/xctool -workspace Blossom.xcworkspace -scheme Blossom_test SYMROOT=${WORKSPACE}/build #PROVISIONING_PROFILE=$ProvisioningProfile }
9:关于NSDateFormatter的格式
G: 公元时代,例如AD公元
yy: 年的后2位
yyyy: 完整年
MM: 月,显示为1-
MMM: 月,显示为英文月份简写,如 Jan
MMMM: 月,显示为英文月份全称,如 Janualy
dd: 日,2位数表示,如02
d: 日,-2位显示,如
EEE: 简写星期几,如Sun
EEEE: 全写星期几,如Sunday
aa: 上下午,AM/PM
H: 时,24小时制,-
K:时,12小时制,-
m: 分,-2位
mm: 分,2位
s: 秒,-2位
ss: 秒,2位
S: 毫秒
IOS开发基础知识--碎片51的更多相关文章
- IOS开发基础知识碎片-导航
1:IOS开发基础知识--碎片1 a:NSString与NSInteger的互换 b:Objective-c中集合里面不能存放基础类型,比如int string float等,只能把它们转化成对象才可 ...
- IOS开发基础知识--碎片33
1:AFNetworking状态栏网络请求效果 直接在AppDelegate里面didFinishLaunchingWithOptions进行设置 [[AFNetworkActivityIndicat ...
- IOS开发基础知识--碎片42
1:报thread 1:exc_bad_access(code=1,address=0x70********) 闪退 这种错误通常是内存管理的问题,一般是访问了已经释放的对象导致的,可以开启僵尸对象( ...
- IOS开发基础知识--碎片50
1:Masonry 2个或2个以上的控件等间隔排序 /** * 多个控件固定间隔的等间隔排列,变化的是控件的长度或者宽度值 * * @param axisType 轴线方向 * @param fi ...
- IOS开发基础知识--碎片3
十二:判断设备 //设备名称 return [UIDevice currentDevice].name; //设备型号,只可得到是何设备,无法得到是第几代设备 return [UIDevice cur ...
- IOS开发基础知识--碎片11
1:AFNetwork判断网络状态 #import “AFNetworkActivityIndicatorManager.h" - (BOOL)application:(UIApplicat ...
- IOS开发基础知识--碎片14
1:ZIP文件压缩跟解压,使用ZipArchive 创建/添加一个zip包 ZipArchive* zipFile = [[ZipArchive alloc] init]; //次数得zipfilen ...
- IOS开发基础知识--碎片16
1:Objective-C语法之动态类型(isKindOfClass, isMemberOfClass,id) 对象在运行时获取其类型的能力称为内省.内省可以有多种方法实现. 判断对象类型 -(BOO ...
- IOS开发基础知识--碎片19
1:键盘事件顺序 UIKeyboardWillShowNotification // 键盘显示之前 UIKeyboardDidShowNotification // 键盘显示完成后 UIKeyboar ...
随机推荐
- App开发:模拟服务器数据接口 - MockApi
为了方便app开发过程中,不受服务器接口的限制,便于客户端功能的快速测试,可以在客户端实现一个模拟服务器数据接口的MockApi模块.本篇文章就尝试为使用gradle的android项目设计实现Moc ...
- PHP实现RTX发送消息提醒
RTX是腾讯公司推出的企业级即时通信平台,大多数公司都在使用它,但是我们很多时候需要将自己系统或者产品的一些通知实时推送给RTX,这就需要用到RTX的服务端SDK,建议先去看看RTX的SDK开发文档( ...
- ASP.NET Aries 入门开发教程7:DataGrid的行操作(主键操作区)
前言: 抓紧勤奋,再接再励,预计共10篇来结束这个系列. 上一篇介绍:ASP.NET Aries 入门开发教程6:列表数据表格的格式化处理及行内编辑 本篇介绍主键操作区相关内容. 1:什么时候有默认的 ...
- 和 Thrift 的一场美丽邂逅
一. 与 Thrift 的初识 也许大多数人接触 Thrift 是从序列化开始的.每次搜索 “java序列化” + “方式”.“对比” 或 “性能” 等关键字时,搜索引擎总是会返回一大堆有关各种序列化 ...
- spring源码分析之context
重点类: 1.ApplicationContext是核心接口,它为一个应用提供了环境配置.当应用在运行时ApplicationContext是只读的,但你可以在该接口的实现中来支持reload功能. ...
- 几个有趣的WEB设备API 前端提高B格必备(一)——电池状态&震动api
受到同事启发,突然发现了几个有趣又实用的web api,没想到前端还有这么多有趣的东西可以玩~~简直过分. 1.电池状态API navigator.getBattery():这个api返回的是一个pr ...
- UVa 122 Trees on the level
题目的意思: 输入很多个节点,包括路径和数值,但是不一定这些全部可以构成一棵树,问题就是判断所给的能否构成一棵树,且没有多余. 网上其他大神已经给出了题目意思:比如我一直很喜欢的小白菜又菜的博客 说一 ...
- ThinkPHP 模板substr的截取字符串函数
ThinkPHP 模板substr的截取字符串函数在Common/function.php加上以下代码 /** ** 截取中文字符串 **/ function msubstr($str, $start ...
- http status code
属于转载 http status code:200:成功,服务器已成功处理了请求,通常这表示服务器提供了请求的网页 404:未找到,服务器未找到 201-206都表示服务器成功处理了请求的状态代码,说 ...
- Flex 布局教程:实例篇
该教程整理自 阮一峰Flexible教程 今天介绍常见布局的Flex写法.你会看到,不管是什么布局,Flex往往都可以几行命令搞定. 我的主要参考资料是Landon Schropp的文章和Solved ...