阻止调用viewDidLoad两次

时间:2014-11-26 20:15:30

标签: ios xcode afnetworking nsxmlparser

我有从API获取json请求并在视图上解析它的场景。但是如果API推送xml链接,我需要使用AFNetworking启动xml解析任务。在解析xml之后,我将xml作为参数(NSData)传递给另一个类方法,我在分析完成后用NSXMLParser分配子值:

-(void)parserDidEndDocument:(NSXMLParser *)parser
{

    ViewController *VS = [[VC alloc] init];

    [VC vastXMLReturn:vastXMLDictionary rollType:rollType];
}

在ViewController中发送参数后,方法负责播放视频;

-(void)vastXMLReturn:(NSDictionary *)xml rollType:(NSString *)roll
{
    NSLog(@"XML responses = %@",xml);

    //NSString *mediaDuration = [xml objectForKey:@"mediaDuration"];

    NSString *mediaFilePath = [xml objectForKey:@"mediaFilePath"];

    //NSArray *trackingLists = [xml objectForKey:@"trackingLinks"];

    advertisementURL = [NSURL URLWithString:roll];

    [self playVideo:advertisementURL initial_time:0];

}

在PlayVideo方法

-(void)playVideo:(NSURL *)videoURL initial_time:(NSTimeInterval)playerTime
{
    theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];


    theMoviPlayer.controlStyle = MPMovieControlStyleNone;

    [self performSelector:@selector(closeButtonForVideoPlayer) withObject:nil afterDelay:5.0];

    theMoviPlayer.movieSourceType = MPMovieSourceTypeFile;

    theMoviPlayer.view.transform = CGAffineTransformConcat(theMoviPlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));

    [self.view addSubview:theMoviPlayer.view];

    //[theMoviPlayer.moviePlayer requestThumbnailImagesAtTimes:@[ @4.3f ] timeOption:MPMovieTimeOptionExact];

    [theMoviPlayer setFullscreen:YES animated:YES];

}

真正的问题是在[theMoviPlayer setFullscreen:YES animated:YES]之后; line,断点在viewDidLoad方法中跳转,这是不应该发生的,因为进程将再次在该方法中启动并且程序终止错误。

我应该怎么做以防止进入viewDidLoad方法?

最好的问候

0 个答案:

没有答案