第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

盡管文件存在于緩存目錄中,UIImage(contentsOfFile :)返回nil

盡管文件存在于緩存目錄中,UIImage(contentsOfFile :)返回nil

偶然的你 2019-07-31 10:39:38
盡管文件存在于緩存目錄中,UIImage(contentsOfFile :)返回nil 我正在嘗試在緩存目錄中保存帶有覆蓋的地圖快照,并在存在時檢索它。但是,盡管創(chuàng)建了文件,但當我嘗試檢索它時,UIImage(contentsOfFile :)返回nil。我已經(jīng)打印了寫入和讀取的文件路徑,它們是相同的,并通過下載容器并檢查目錄并且文件確實存在來驗證文件是否存在。知道這里的問題是什么嗎?let cachesDirectory: URL = {     let urls = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)     return urls[urls.endIndex - 1]}()let mapCachesDirectory = cachesDirectory.appendingPathComponent("map-snapshots", isDirectory: true)func configureMap(data: NSSet?) {     mapView.isZoomEnabled = false     mapView.isScrollEnabled = false     mapView.isUserInteractionEnabled = false     guard let data = data as? Set<SessionData>, data.count > 0 else { return }     activityIndicatorView.isHidden = false     activityIndicatorView.startAnimating()     DispatchQueue.global(qos: .userInitiated).async {         var points = [CLLocationCoordinate2D]()         for object in data {             guard object.locationLatitude != 0, object.locationLatitude != 0 else { continue }             points.append(CLLocationCoordinate2DMake(object.locationLatitude, object.locationLongitude))         }         DispatchQueue.main.async(execute: {             self.createOverlay(points: points)             self.activityIndicatorView.stopAnimating()             self.activityIndicatorView.isHidden = true             self.cacheMapImage(view: self.mapView)         })     }}func cacheMapImage(view: UIView) {     UIGraphicsBeginImageContextWithOptions(view.bounds.size, true, 0)     view.drawHierarchy(in: view.bounds, afterScreenUpdates: true)     let compositeImage = UIGraphicsGetImageFromCurrentImageContext()     UIGraphicsEndImageContext()
查看完整描述

2 回答

?
jeck貓

TA貢獻1909條經(jīng)驗 獲得超7個贊

問題是您正在使用URL屬性absoluteString,您應(yīng)該使用path屬性。absoluteStringpath屬性之間的區(qū)別在于absoluteString包含文件url方案(“file://”),這是它沒有找到應(yīng)該是它的路徑的文件但它實際上是它的absoluteString的原因。


查看完整回答
反對 回復(fù) 2019-07-31
?
臨摹微笑

TA貢獻1982條經(jīng)驗 獲得超2個贊

atPath: self.mapCachesDirectory.absoluteString應(yīng)該是atPath: self.mapCachesDirectory.path

查看完整回答
反對 回復(fù) 2019-07-31
  • 2 回答
  • 0 關(guān)注
  • 1791 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號