ios - iPhone 被锁定时无法访问 Documents 目录?

标签 ios iphone objective-c lockscreen documentsdirectory

场景 1。我使用此代码使用 Dropbox SDK 从 Dropbox 下载文件。

-(void)downloadFile:(DBMetadata*)file
{
    if (!file.isDirectory)
    {
        NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
        NSString *localPath = [documentsPath stringByAppendingPathComponent:file.filename];

        [[self restClientForDownload] loadFile:file.path intoPath:localPath];

    }

}

场景 2. 每当我想播放 Documents 目录中的歌曲时。当 iPhone 获取密码锁定时,它不会播放。当前歌曲也在几分之一秒内停止。

最佳答案

这是不可能的。但是,您可以“防止”您的手机在您的应用程序运行时锁定。 [UIApplication sharedApplication].idleTimerDisabled = YES 应该这样做。

关于ios - iPhone 被锁定时无法访问 Documents 目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22155220/

相关文章:

ios - UITableView框架基于单元格数

ios - 有时会返回 Google 距离矩阵 ZERO_RESULTS

iphone - 在运行 iPhone 单元测试时查找内存泄漏

iPhone RestKit 加载 NSManagedObject 而不是 NSManagedObject+(ActiveRecord)

ios - 使用Xcode 9创建iOS通用框架

ios - Google PlacePicker API - 小数点后的地理坐标精度(Swift 3.0)

ios - 从 NSDictionary 对象的 NSArray,如何获得 uniques 的 NSArray

带有附件 View 的 iOS 8 自调整单元格

ios - 单元格高度无法正常工作

objective-c - 减少 UITableViewController 中提供的数据集的正确方法