所以我对编码一般都很陌生(我的背景是在视频制作中),而且我的任务是创建一个iPhone应用程序。实际上,Xcode在教程等方面非常简单,但是我已经遇到了一些我不知道的东西。无论如何...在这里。为什么我的应用不能正确解析视频链接?
我遵循YouTube上关于解析iOS中的XML的教程。很棒。但是,本教程将XML解析为标签。那部分工作完美。但是,我试图使用自定义的XML文档来解析播客RSS提要,并且我希望视频的链接转到播放按钮,而不是填写标签。所以我认为我可以将已经工作的链接传递给使用MPMoviePlayerViewController的按钮。没有工作。
它给出了有关将NSString作为URL传递的错误。然后我使用NSUrl来制作视频链接。没有错误,但视频不播放。我做错了什么想法?
我包含的唯一代码是DetailViewController.m文件,与其他所有工作一样,即使链接正确显示在标签中。它只是没有正确连接到按钮。当您点击模拟器中的播放按钮时,它会启动电影播放器,并只显示“加载...”屏幕。任何帮助将不胜感激。
#import "DetailViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@implementation DetailViewController
@synthesize theList;
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = theList.title;
theTitle.text = theList.title;
theAuthor.text = theList.author;
playAudio.text = theList.audio;
playVideo.text = theList.video;
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (IBAction)playVid:(id)sender {
NSURL *playVid = [NSURL URLWithString:theList.video];
MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:playVid];
[mpViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
[self presentMoviePlayerViewControllerAnimated:mpViewController];
}
@end
你确定你得到一个有效的NSURL实例吗? – 2012-07-05 18:21:01
我不确定。我不知道如何检查。我知道URL是正确的,因为它正确传递到标签。你知道任何有关如何检查NSURL接收的教程吗? – user1499854 2012-07-05 19:08:52
在创建'playVid'之后添加'NSLog(@“%@”,playVid);并查看控制台中显示的内容。 – 2012-07-05 19:11:20