场景 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/