相关疑难解决方法(0)

iOS临时文件夹位置

我的应用程序刚被Apple拒绝,因为它将临时文件或缓存文件存储在文档目录中.对.他们的拒绝消息说明:

应用程序使用的临时文件只应存储在/tmp目录中

我想除了Application文件夹中的Documents and Library之外.

我现在正试图在iPhone模拟器中调试此问题,当我使用时NSTemporaryDirectory(),我在Xcode调试器中获得的值是/var/folders/yj/gnz1c7156c7d6d4fj429yms40000gn/T/tempzip.zip,而不是/Users/me/Library/Application Support/iPhone Simulator/5.1/Applications/8F71AB72-598C-427A-A116-36833D3209F7/tmp/tempzip.zip.

所以:NSTemporaryDirectory()使用iPhone模拟器有不同的行为,是否可以在调试时跟踪应用程序的临时目录?

objective-c temporary-directory ios

24
推荐指数
4
解决办法
3万
查看次数

Swift - 使用downloadTaskWithURL下载视频

我正在下载一个视频,感谢downloadTaskWithURL,我用这段代码将它保存到我的画廊:

    func saveVideoBis(fileStringURL:String){

    print("saveVideoBis");

    let url = NSURL(string: fileStringURL);
    (NSURLSession.sharedSession().downloadTaskWithURL(url!) { (location:NSURL?, r:NSURLResponse?, e:NSError?) -> Void in

        let mgr = NSFileManager.defaultManager()

        let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0];

        print(documentsPath);

        let destination = NSURL(string: NSString(format: "%@/%@", documentsPath, url!.lastPathComponent!) as String);

        print(destination);

        try? mgr.moveItemAtPath(location!.path!, toPath: destination!.path!)

        PHPhotoLibrary.requestAuthorization({ (a:PHAuthorizationStatus) -> Void in
            PHPhotoLibrary.sharedPhotoLibrary().performChanges({
                PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(destination!);
                }) { completed, error in
                    if completed {
                        print(error);
                        print("Video is saved!");
                        self.sendNotification();
                    }
            }
        })
    }).resume()
}
Run Code Online (Sandbox Code Playgroud)

它在我的模拟器上工作得非常好,但在我的iPad上,即使print("Video is saved!");显示,视频也不会保存.你知道为什么吗?

我的控制台中也出现了该消息

无法从文件创建数据(null)

iphone ipad ios nsurlsessiondownloadtask swift

10
推荐指数
1
解决办法
8849
查看次数

如何在iOS中显示来自网络的pdf

目前我正在使用QuickLook模块从网络打开pdf,但它显示一个空白页面,错误"无法为网址发布文件扩展名:https://testing-xamidea.s3.amazonaws.com/flowchart/20171103182728150973368.pdf "在控制台.我猜QuickLook只能打开本地保存的Pdf文件.是否可以使用quicklook从网络加载pdf?.到目前为止这是我的代码 - {fileURL包含要加载pdf的url,也设置了委托等)

extension FlowchartVC:QLPreviewControllerDelegate,QLPreviewControllerDataSource {
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return 1
 }  
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {

let url : NSURL! = NSURL(string : fileURL)
return url
 }
   func previewControllerWillDismiss(_ controller: QLPreviewController) {
 self.dismiss(animated: true, completion: nil)
 }
}
Run Code Online (Sandbox Code Playgroud)

xcode quicklook ios swift

0
推荐指数
1
解决办法
2252
查看次数