2012-02-19 3 views
0

모두 안녕하세요. iOS 5에서 비디오를 재생할 때 문제가 있습니다. 프로그램을 만들 때 "로컬 인스턴스 선언을 숨김"이라는 경고가 나타나고 프로그램을 실행하고 버튼을 누릅니다. 나는 "SIGABRT"를 얻는다. 그리고 나는 무엇을 해야할지 모르겠다. 내가 얻을 수있는 모든 도움은 충분하다. !! 사전iOS 5 동영상 플레이어

MY .H 파일

#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 방법의 첫 번째 줄을 제거

 #import <MediaPlayer/MediaPlayer.h> 

    @interface MainViewController : UIViewController { 

    MPMoviePlayerController *moviePlayer; 


} 


-(IBAction)Video:(id)sender; 

@end 

MY하는 .m 파일에

들으.

MPMoviePlayerController *moviePlayer; //this line; 

.h 파일에 이미 그러한 변수가 선언 되었기 때문에.

0

동일한 변수 이름을 두 번 선언했음을 의미합니다. 하나는 .h 파일에, 다른 하나는 .m 파일에 선언되었습니다.

관련 문제