美文网首页
遇到的问题

遇到的问题

作者: Jackson_Z | 来源:发表于2017-02-27 11:16 被阅读87次

    appcode 不能真机运行

    最下面把这个调到手机系统版本 一下
    改为自动签名,添加开发账号teamId(打开证书页地址栏后面有)

    Error:Safe Area Layout Guide before iOS 9.0

    配置为9.0及以上就行了

    reason: image not found 真机运行 charts 报错

    reason: image not found的解决方案

    image.png

    MJ-refresh 导致内存泄漏

    @weakify(self);
    tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
            @strongify(self);
            [self loadNewPositions];
        }];
    

    出处

    UIWebView内存泄漏问题

    - (void)webViewDidFinishLoad:(UIWebView *)webView {
      [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"WebKitCacheModelPreferenceKey"];
    }
    

    来至

    完美解决SDWebImage不断加载图片内存崩溃的问题

    每次加载更多内容的时候都执行一次,在使用SDWebImage加载较多图片造成内存警告时,定期调用

     [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];
    

    出处
    使用SDWebImage和YYImage下载高分辨率图,导致内存暴增的解决办法
    完美解决SDWebImage加载多个图片内存崩溃的问题

    SDWebImage大家肯定都恨熟悉了,国内外太多的App使用其进行图片加载。
    但是最近在使用过程中发现,我用SDWebImage加载多个图片,类似微博动态那种,在加载的过程中。我发现当图片分辨率比较大的时候(不是图片大),加载几张图片就崩溃了。
    网上说可以每次加载图片清空memcache,但是效果并不好。
    [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];
      
    
    这地方采用的方法是:
    第一步:在 UIImage+MultiFormat这个类里面添加如下压缩方法
    +(UIImage *)compressImageWith:(UIImage *)image
    {
        float imageWidth = image.size.width;
        float imageHeight = image.size.height;
        float width = 320;
        float height = image.size.height/(image.size.width/width);
        
        float widthScale = imageWidth /width;
        float heightScale = imageHeight /height;
        
        // 创建一个bitmap的context
        // 并把它设置成为当前正在使用的context
        UIGraphicsBeginImageContext(CGSizeMake(width, height));
        
        if (widthScale > heightScale) {
            [image drawInRect:CGRectMake(0, 0, imageWidth /heightScale , height)];
        }
        else {
            [image drawInRect:CGRectMake(0, 0, width , imageHeight /widthScale)];
        }
        
        // 从当前context中创建一个改变大小后的图片
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        // 使当前的context出堆栈
        UIGraphicsEndImageContext();
        
        return newImage;
        
    }
    第二步: 在下面这个方法里调用压缩方法
    + (UIImage *)sd_imageWithData:(NSData *)data {
        UIImage *image;
        NSString *imageContentType = [NSData sd_contentTypeForImageData:data];
        if ([imageContentType isEqualToString:@"image/gif"]) {
            image = [UIImage sd_animatedGIFWithData:data];
        }
    #ifdef SD_WEBP
        else if ([imageContentType isEqualToString:@"image/webp"])
        {
            image = [UIImage sd_imageWithWebPData:data];
        }
    #endif
        else {
            image = [[UIImage alloc] initWithData:data];
            if (data.length/1024 > 90) {
                image = [self compressImageWith:image];
            }
            UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data];
            if (orientation != UIImageOrientationUp) {
                image = [UIImage imageWithCGImage:image.CGImage
                                            scale:image.scale
                                      orientation:orientation];
            }
        }
    
    
        return image;
    }
     第三步:
    就是在SDWebImageDownloaderOperation的connectionDidFinishLoading方法里面的:
     UIImage *image = [UIImage sd_imageWithData:self.imageData];
      NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL];
      image = [self scaledImageForKey:key image:image];
      NSData *data = UIImageJPEGRepresentation(image, 1);
      self.imageData = [NSMutableData dataWithData:data];
    
    最后;再配合    [[SDImageCache sharedImageCache] setValue:nil forKey:@"memCache"];(图片加载后使用)大功告成,亲测内存基本变化不大,自动释放也来得及。
    

    完美解决SDWebImage加载多个图片内存崩溃的问题

    改了微信开发平台软件图标,友盟分享到微信好友小图标不变

    更改了微信开发平台的小图标之后,出现小图标未改变的设备都是之前使用过旧图标分享过的设备,这才确定到是缓存问题。于是将显示的不是最新的小图标的设备清理了微信缓存之后,再次分享,显示出了最新的图标;但是有的设备则需要删除微信,重新下载安装微信才能正常显示最新的小图标 来源:http://blog.csdn.net/wuzesong/article/details/51888274

    网络加载报错1009

    解决:启动时加载的sdk过多,把不必要的删除,也可能和sdk加载的顺序有关

    AFN 报错 Error Domain=NSCocoaErrorDomain Code=3840 "Number wound up as NaN around character 794." UserInfo={NSDebugDescription=Number wound up as NaN around character 794

    服务器返回的json数据问题 超出NSNumber范围 经纬度度竟然为5e-324,让服务器端修改成正常的小数点后八位的数据,问题就解决了。问题就是4.2E-324这个数据带小数点太长了,以至于NSNmber都装不下造成的数据越位。

    Valid JSON, but being deemed as failure with 'Cocoa error 3840'
    iOS开发:AFNetWorking请求报错:NSDebugDescription=Number wound up as NaN around character
    Valid JSON, but 'Cocoa error 3840' from AFNetworking/NSJSONSerialization

    iOS中使用第三方键盘UIKeyboardWillShowNotification执行多次

    -(void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:YES];
        IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
        manager.enableAutoToolbar = NO;//键盘中间显示placeholder的部分
        manager.enable = NO;
    }
    -(void)viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:YES];
        IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
        manager.enableAutoToolbar = NO;
        manager.enable = NO;
    }
    #pragma mark - 键盘通知的方法
    -(void)keyboardWillShow:(NSNotification *)notice {
        NSDictionary *info = [notice userInfo];
        CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
        
        CGRect beginRect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
        CGRect endRect   = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    
        NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
        CGFloat h = [value CGRectValue].size.height;
    
        // 第三方键盘回调三次问题,监听仅执行最后一次 兼容第三方键盘
        if(beginRect.size.height > 0 && (beginRect.origin.y - endRect.origin.y > 0)) {
            //TODO:
        }
           
    }
    

    iOS中使用第三方键盘UIKeyboardWillShowNotification执行多次

    相关文章

      网友评论

          本文标题:遇到的问题

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