美文网首页
iOS 开发中遇到的坑

iOS 开发中遇到的坑

作者: 747071ac3c1d | 来源:发表于2016-12-20 10:43 被阅读1339次

1.使用百度地图报BMK_SEARCH_PERMISSION_UNFINISHED(还未完成鉴权,请在鉴权通过后重试)错误

原因是  在这个方法onGetPermissionState还没授权完就开始掉 定位或反地理搜索

解决方案:解决方案:需要先等BMKMapManager调用start:generalDelegate:之后的onGetPermissionState回调返回0之后,表示你已经取得权限,才能调用地图POI数据接口


2.UIWebview加载https链接空白的问题

在你的webView所在视图控制器中加入下面这三个方法 参考链接地址 http://stackoverflow.com/questions/11573164/uiwebview-to-view-self-signed-websites-no-private-api-not-nsurlconnection-i 

/**这两个字段为了适配UIWebview 适配https*/

@property (nonatomic, assign) BOOL authenticated;

@property (nonatomic, strong) NSURLRequest *failedRequest;

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

BOOL result = _authenticated;

if (!_authenticated) {

_failedRequest = request;

NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

[urlConnection start];

}

return result;

}

-(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {

if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {

//NSURL* baseURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@", wwjWebView.request.URL]];

NSURL* baseURL = [_failedRequest URL];

if ([challenge.protectionSpace.host isEqualToString:baseURL.host]) {

DLog(@"trusting connection to host %@", challenge.protectionSpace.host);

[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];

} else

DLog(@"Not trusting connection to host %@", challenge.protectionSpace.host);

}

[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];

}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)pResponse {

_authenticated = YES;

[connection cancel];

[wwjWebView loadRequest:_failedRequest];

}


3. SDWebImage加载Https图片失败

在使用sd_setImageWithURL:  加载图片时,将options 这个参数设置为SDWebImageAllowInvalidSSLCertificates就好了

这是我项目中用到的 到时根据自己的需要来添加  不知道为什么有时会不起作用

WeakSelf(weakSelf);

[self.avatarImageView sd_setImageWithURL:url placeholderImage:placeImage options:SDWebImageAllowInvalidSSLCertificates | SDWebImageRefreshCached completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

weakSelf.avatarView.backgroundColor = [UIColor colorWithHex:0xe7e5ea];

}];

方法二、在sdwebimage中 找到SDWebImageDownloaderOperation.m文件 用下面的方法把那个方法替换掉 本人已经试过了 可以使用的

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

{

if ([challenge previousFailureCount]== 0) {

//NSURLCredential 这个类是表示身份验证凭据不可变对象。凭证的实际类型声明的类的构造函数来确定。

NSURLCredential* cre = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];

[challenge.sender useCredential:cre forAuthenticationChallenge:challenge];

}

else{

}

}

4. 环境 xCode8 iOS10 操作:新浪微博的第三方登录  kCFStreamErrorDomainSSL, -9824

此问题应该是ssl证书版本不兼容的问题  在项目info.plist中像下面的图配置一下就可以了 记得要clean一下 在试试  也可以参考https://github.com/sinaweibosdk/weibo_ios_sdk  配置白名单


相关文章

  • iOS开发中遇到过的坑

    iOS开发中遇到过的坑 iOS开发中遇到过的坑

  • iOS开发中遇到的坑

    从事iOS开发已有数年,一路走来踩过无数的坑,然而都踩过哪些坑,如今想来脑子里竟是一片空白,为什么呢?仔细想了想,...

  • iOS 开发中遇到的坑

    1.使用百度地图报BMK_SEARCH_PERMISSION_UNFINISHED(还未完成鉴权,请在鉴权通过后重...

  • ios开发中遇到的坑

    这篇文章的内容包含:UITableViewCell的真实结构在iOS的环境下使用正则表达式如何优雅的隐藏tabba...

  • iOS开发中遇到的坑

    首先声明,这篇文章大部分是我从cocoaChina上面看的一篇文章www.cocoachina.com/ios/2...

  • iOS开发中遇到的坑

    1.iOS中NSString类型转换成Float类型会出现精度不准确的问题,如果用于数字的比较会出现比较大大问题!...

  • App定位和地图的那些坑

    开发App时会遇到各种坑,本文分享我们在iOS/Android系统中定位和地图中遇到的坑,以及携程App的解决方案...

  • 2018-12-21

    iOS开发中懒加载遇到的坑 正常写一个懒加载对象 - (MAMapView*)mapView{ if(nil=...

  • iOS开发中 经常遇到的坑

    1.XCode8的项目在xcode7运行报错: 有两种方法解决这个问题: 1.你同事也升级Xcode8,比较推荐这...

  • 记录iOS开发中遇到的坑

    1.关于本地化数据(NSUserDefault) 当关键数据在iOS版本更新时发生数据类型改变时,最好使用新的ke...

网友评论

      本文标题:iOS 开发中遇到的坑

      本文链接:https://www.haomeiwen.com/subject/ugpxvttx.html