你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS開發根底知識--碎片51

IOS開發根底知識--碎片51

編輯:IOS開發綜合

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:@"&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<=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];
    }
}

 

【IOS開發根底知識--碎片51】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved