0

我在应用程序加载而不是图像时开发启动视频。并且​​还使用 ios 中的推送视图控制器导航到下一页。但我不知道这是否是正确的代码。但我使用这个一些问题发生在第三页但它没有被使用我的应用程序加载正常。我的示例代码在这里。

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self videopage];
// Do any additional setup after loading the view, typically from a nib.
}

-(void)videopage
{
    NSURL * url=[NSURL URLWithString:@"http://xyz.opening_ani.mp4"];
    MPMoviePlayerController * videos =[[MPMoviePlayerController alloc]initWithContentURL:url];
    videos.view.frame=CGRectMake(0, 0, 1024, 768);
    videos.controlStyle=MPMovieControlStyleNone;
    [self.view addSubview:videos.view];
    [videos play];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(startParsing) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; 
  //[self startParsing];
}

-(void)startParsing
{
    ViewController * navigation=[[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil]autorelease];
    [self.navigationController pushViewController:navigation animated:NO];
}
4

1 回答 1

0

请使用以下代码。我认为,您的通知对象nil无法正常工作。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startParsing:)
                                             name: MPMoviePlayerPlaybackDidFinishNotification
                                           object:videos];

- (void)startParsing:(NSNotification *)noti
{
   ViewController * navigation=[[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil]autorelease];
    [self.navigationController pushViewController:navigation animated:NO];
}
于 2012-08-15T08:23:29.753 回答