I'm trying to build an iphone app that plays a video then switches view to an info page after. The user can then switch back to the original view before the video plays after reading the info page. I can get the first switch to happen but not the second for some reason. I get a sigabort error that highlights this in the AppDelegate:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([videoPlayAppDelegate class]));
Here is my code for the first switch...
videoPlayViewController.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import "View2.h"
@interface videoPlayViewController : UIViewController
<MPMediaPickerControllerDelegate, UIAlertViewDelegate>
{
MPMoviePlayerController *moviePlayer;
}
@property (strong, nonatomic) MPMoviePlayerController *moviePlayer;
-(IBAction) playMovie;
@end
videoPlayViewController.m
#import "videoPlayViewController.h"
@implementation videoPlayViewController
@synthesize moviePlayer;
-(void)playMovie
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"sample" ofType:@"mov"]];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = NO;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
[moviePlayer.view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
NSLog(@"This method is working");
View2 *second =[[View2 alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
}
//[player.view removeFromSuperview];
}
Here's how I switch back...
View2.h
#import <UIKit/UIKit.h>
#import "videoPlayViewController.h"
@interface View2 : UIViewController
-(IBAction) goBack;
@end
View2.m
#import "View2.h"
@interface View2 ()
@end
@implementation View2
-(IBAction) goBack
{
//Figure this out
videoPlayViewController *map =[[videoPlayViewController alloc] initWithNibName:@"videoPlayViewController" bundle:nil];
[self presentModalViewController:map animated:YES];
}