2012-07-30 4 views
0

그래서 미디어 플레이어를 재생하는 거의 IBAction 인 함수를 작성하려고합니다. 이것은 필자가 작성한 코드에서 필자의 코드를 간결하게 만들기 위해 여러 개의 비디오가 사용될 것이므로 미디어 플레이어의 코드가 여러 번이 아닌 한 번에 들어가도록 함수를 작성하고 싶습니다. 아래 코드를 시도하면 "예상 표현"이라는 IBAction에 오류가 있음을 나타냅니다. 어떤 아이디어? 또한 코드에 포함 된 경우에는 작동하지 않는 if 문이 주석 처리됩니다. 기본적으로 전체 화면 미디어 플레이어에 제공된 기본 "완료"버튼을 클릭하면 창이 닫힙니다. 지금 완료된 버튼은 비디오를 멈추게하지만 미디어 플레이어도 닫으려고합니다. 코드의이 부분에서함수 내에서 예상되는 표현 오류

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; 


} 
} 

답변

0

봐 :

void moviePlayer (id vidName, id type){ 


-(IBAction)playMovie{ 

당신은 목표 C 방법을 시작하려고 다음 C 기능을 시작하고 닫습니다하지 않고. 아마도 더 잘 작동할까요?

void moviePlayer (id vidName, id type){ 
} 
-(IBAction)playMovie{ 
    // other code 
} 
+0

IBAction이 함수에 포함되지 않도록 해당 대괄호가 함수를 닫지는 않습니다. 기능 본체에 아무 것도 없기 때문에이 기능을 쓸모 없게 만들 것입니다. – Pkolms

+0

정확합니다. 함수에서 함수를 사용할 수 없으며 메서드에서 메서드를 사용할 수도 있고 yyy를 함께 사용하여 비슷한 xxx를 사용할 수도 있습니다. – demosten

관련 문제