所以我尝试使用视频作为背景,并且我的应用程序中有一个 .mov
文件,当我运行此代码时:
NSBundle * bundle = [NSBundle mainBundle];
NSString * urlString = [bundle pathForResource:@"movie" ofType:@"mov"];
NSURL * movieURL = [NSURL URLWithString:urlString];
if (!movieURL) {
NSLog(@"Not valid");
}
我在控制台中收到无效
。我检查了 urlString
,它给了我一个 url,我确信该文件命名正确并且不在目录中。
所以文件就在那里并被复制到源中。不知道为什么要这样做。
最佳答案
您想使用:
NSURL *moveiURL = [NSURL fileURLWithPath:urlString];
更好的是,使用:
NSURL *moveURL = [bundle URLForResource:@"movie" withExtension:@"mov"];
关于ios - NSBundle 路径中的 NSURL 返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25633573/