1:https關閉證書跟功能變數名稱的驗證 如果報 In order to validate a domain name for self signed certificates, you MUST use pinning 也是上面這種方式進行解決 2: iOS UIWebView 訪問https繞過證書驗 ...
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
5:強制去除HTML標簽的文本
+ (NSString *)getStandarString:(NSString *)str { NSArray *components = [str componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]]; NSMutableArray *componentsToKeep = [NSMutableArray array]; for (int i = 0; i < [components count]; i = i + 2) { 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<=0){ [UIView animateWithDuration:[animationTime doubleValue] animations:^{ self.view.frame =CGRectMake(0, keyHeight, WIDTH(self.view), HEIGHT(self.view)); } completion:^(BOOL finished) { }]; } }
pragma mark–鍵盤隱藏事件
(void)keyBoardDidHide:(NSNotification *)notification{ self.view.frame = CGRectMake(0, 0, 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>0 && (begin.origin.y-end.origin.y>0)){ keyBoardHeight = curkeyBoardHeight; [self showKeyboard:notification]; } }