0
所以我想寫一個功能,幾乎只是一個播放媒體播放器的IBAction。在編寫的代碼中,這是非常必要的,因爲將會使用多個視頻,以便使我的代碼更加簡潔,我希望編寫該函數,以便媒體播放器的代碼只進入一次,而不是幾次。當我嘗試下面的代碼時,它聲明我在IBAction上有一個錯誤,指出「預期表達式」。有任何想法嗎?代碼中還包含註釋掉的語句,如果不起作用。本質上,我希望這樣,當我點擊全屏媒體播放器中提供的默認「完成」按鈕時,該窗口將關閉。現在,所有完成按鈕都會停止播放視頻,但我希望媒體播放器也可以關閉。功能內的預期表達式錯誤
void moviePlayer (id vidName, id type);
void moviePlayer (id vidName, id type){
-(IBAction)playMovie{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"vidName" ofType:@"type"]];
MPMoviePlayerController *playerViewController = [[MPMoviePlayerController alloc] init];
playerViewController.contentURL = url;
if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight){
playerViewController.view.frame = CGRectMake(0, 0, 1030, 768);
}
else{
playerViewController.view.frame = CGRectMake(0,0, 768, 1004);
}
[playerViewController setControlStyle: MPMovieControlStyleFullscreen];
[playerViewController setScalingMode:MPMovieScalingModeAspectFit];
playerViewController.view.AutoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:playerViewController.view];
[playerViewController play];
/*if (playerViewController == stop){
[self.playerViewController.view removeFromSuperview];
}*/
self.playerViewController = playerViewController;
}
}
不會那個括號剛剛關閉該函數,以便IBAction不會包含在該函數中。我覺得這會導致函數無用,因爲函數體 – Pkolms 2012-07-31 23:12:02
中沒有任何內容正確。你不能在函數中使用函數,或者在方法中使用函數,或者在兩者的yyy組合中使用類似的xxx。 – demosten 2012-08-02 19:21:26