2012-02-19 18 views
0

皆さん、iOS 5でビデオを再生する際に問題が発生しました。プログラムをビルドするときに、「インスタンス変数を非表示にする」という警告が表示され、プログラムを実行してボタンをタップします私は "SIGABRT"を取得します。そして、私は何をすべきかわからない、私が得ることができるすべての助成金はaprriciatedです!iOS 5ムービープレーヤー

事前にThxを

MY .hファイル

 #import <MediaPlayer/MediaPlayer.h> 

    @interface MainViewController : UIViewController { 

    MPMoviePlayerController *moviePlayer; 


} 


-(IBAction)Video:(id)sender; 

@end 

MY .mファイル

#import "MainViewController.h" 

@interface MainViewController() 

@end 


@implementation MainViewController 


-(IBAction)Video:(id)sender { 

MPMoviePlayerController *moviePlayer; 
NSString *path = [[NSBundle mainBundle] pathForResource:@"big-buck-bunny-clip" ofType:@"m4v"]; 
NSURL *videoURL = [NSURL fileURLWithPath:path]; 
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL]; 
[moviePlayer setControlStyle:MPMovieControlStyleDefault]; 
[moviePlayer.view setFrame: self.view.bounds]; 
[self.view addSubview: moviePlayer.view]; 
[moviePlayer prepareToPlay]; 
[moviePlayer play]; 
} 



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

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

@end 

答えて

0
local declaration of hides instance variables 

あなた-(IBAction)Video:(id)sender方法の最初の行を削除します。

MPMoviePlayerController *moviePlayer; //this line; 

.hファイルにこのような変数が既に宣言されているためです。

0

同じ変数名を2回、つまり.hファイルと.mファイルで2回宣言したことを意味します。