2010-06-23 5 views
0

lors de l'exécution sur le périphérique 3.1.2, pourquoi cela passe également if (NSClassFromString (@ "MPMoviePlayerViewController")! = nul) et faire du code de iOS4 alors il va planter, comment résoudre ce problème?comment faire pour que le périphérique 3.1.3 ne passe pas if (NSClassFromString (@ "MPMoviePlayerViewController")! = Nil) cette condition

if(NSClassFromString(@"MPMoviePlayerViewController") != nil) { 
        // iOS 4 code 
     NSLog(@"MPMoviePlayerViewController"); 
     MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:AppDelegate.PushLink]]; 
     if (mp) { 
     // save the movie player object 
     self.theMovie4 = mp; 
     [mp release]; 
     //Present 
     [self presentMoviePlayerViewControllerAnimated:self.theMovie4]; 

     // Play the movie! 
     self.theMovie4.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming; 
     [self.theMovie4.moviePlayer play]; 
     } 
     } 
     else { 
         //iOS 3 Code 
     AppDelegate = nil; 
     AppDelegate = [[UIApplication sharedApplication] delegate]; 
     [AppDelegate ForceHideNavigationBar]; 
     theMovie3 = nil; 

     [[NSNotificationCenter defaultCenter] addObserver:self 
     selector:@selector(moviePreloadDidFinish:) 
     name:MPMoviePlayerContentPreloadDidFinishNotification 
      object:theMovie3]; 

     [[NSNotificationCenter defaultCenter] addObserver:self 
     selector:@selector(moviePlayBackDidFinish:) 
     name:MPMoviePlayerPlaybackDidFinishNotification 
      object:theMovie3]; 

     // Register to receive a notification when the movie scaling mode has changed. 
     [[NSNotificationCenter defaultCenter] addObserver:self 
     selector:@selector(movieScalingModeDidChange:) 
     name:MPMoviePlayerScalingModeDidChangeNotification 
      object:theMovie3]; 

     theMovie3 = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString:AppDelegate.PushLink]]; 

     [theMovie3 play]; 

     } 

Répondre

1

J'utilisé:

if (NSClassFromString(@"MPMoviePlayerViewController") != nil 
    && [UIViewController instancesRespondToSelector: @selector(presentMoviePlayerViewControllerAnimated:)]) { 
    // iOS 4 
+0

Merci Dave Lee – RAGOpoR

Questions connexes