首页 技术 正文
技术 2022年11月23日
0 收藏 573 点赞 3,490 浏览 4484 个字

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:@"&nbsp;" 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: 毫秒
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,910
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,435
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,250
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,061
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,693
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,731