예를 들어 두 개의 uiview가 있고 첫 번째보기에는 두 번째보기에서 비디오를 재생하는 하나의 rect 버튼 만 있습니다. 아이디어는 사용자가 재생 버튼을 누르면, 두 번째보기가 나타나고 설정 위치에서 비디오를 재생합니다.이상한 애니메이션 동영상을 사용하는 경우
MPMoviePlayerController *player;
NSURL *videoURL;
IBOutlet UIView *mainView;
IBOutlet UIView *secondView;
}
-(IBAction)view:(id)sender;
-(IBAction)back:(id)sender;
@property (nonatomic, retain) MPMoviePlayerController *player;
-(void)playVideo;
@end
및 구현 파일 : 헤더 파일에
: 여기 내가 그것을 위해 한 일이다
-(void)playVideo {
videoURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test2.mov" ofType:nil]];
player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[player prepareToPlay];
[secondView addSubview:player.view];
player.view.frame = CGRectMake(92, 137, 804, 473);
[player.backgroundView addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test2.png"]]];
player.scalingMode = MPMovieScalingModeFill;
player.view.backgroundColor = [UIColor clearColor];
player.controlStyle = MPMovieControlStyleNone;
[player play];
}
-(IBAction)view:(id)sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDelay:0.1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
mainView.frame = CGRectMake(-1024, 0, 1024, 748);
secondView.frame = CGRectMake(0, 0, 1024, 748);
[UIView commitAnimations];
[self performSelector:@selector(playVideo) withObject:nil afterDelay:3.0];
애니메이션이 잘 작동하고 비디오 코드에 설정된 재생 . 하지만 문제는 비디오가 현재 설정된 위치에서 재생되지 않는다는 것입니다. "player.view.frame = CGRectMake (92, 137, 804, 473);" 대신 x, y 점에서 애니메이션을 시작하고 전체 프레임을 채 웁니다 (804,473). 그래서 플레이어 레이어가 애니메이션되기 전에 게임이 시작됩니다. 나는 플레이어가 고정 된 위치에서 플레이하기를 원한다. 이 모든 솔루션?
#import <QuartzCore/QuartzCore.h>
하는 .m 파일 : 여기
내가 이미 무슨 짓을했는지[secondView.layer removeAllAnimations];
그리고 난 이미 거의 모든 솔루션을 여기 읽을 수 있지만 "정말"그 대답 중 어느 것도 UIView의 애니메이션을 중지 작동하지 않습니다 그래서 그 선수에게 영향을주지 않습니다. 고마워, 너 정말 도움이 돼서 고마워.