大家好我在iOS 5中播放视频时遇到问题。当我构建程序时,我收到警告“隐藏实例变量的本地声明”,当我运行程序并点击按钮时,我得到一个“ SIGABRT”。我不知道该怎么做,我能得到的所有帮助都是有益的!
提前谢谢
我的.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 :(得分:0)
local declaration of hides instance variables
删除-(IBAction)Video:(id)sender
方法的第一行。
MPMoviePlayerController *moviePlayer; //this line;
因为您已经在.h文件中声明了这样的变量。
答案 1 :(得分:0)
表示您声明了两次相同的变量名,一个在.h文件中,另一个在.m文件中。