iPhone - 将视频显示为启动画面

时间:2011-01-01 19:02:06

标签: iphone video splash-screen

我要求在我的iphone应用中将视频显示为启动画面 我正在使用以下代码:

-(void)setupMovie{
NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"iphone" ofType:@"mp4"];
NSURL* movieURL = [NSURL fileURLWithPath:moviePath];

playerCtrl =  [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
playerCtrl.scalingMode = MPMovieScalingModeFill;
playerCtrl.controlStyle = MPMovieControlStyleNone;
playerCtrl.view.frame = CGRectMake(0, 0, 480, 320);

[[NSNotificationCenter defaultCenter] addObserver:self 
                     selector:@selector(moviePlayBackDidFinish:) 
                              name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setFrame:CGRectMake(0, 0, 480, 320)];
[playerCtrl.view setTransform:CGAffineTransformMakeRotation(-M_PI/2)];
[self.window addSubview:playerCtrl.view];
[playerCtrl play];}

但是玩家视图不是从x = 0,y = 0位置开始。是什么原因以及如何解决它。 它的起始点x = 100,y = 100(约)。

2 个答案:

答案 0 :(得分:0)

您正在设置影响位置三次的信息

playerCtrl.view.frame = CGRectMake(0, 0, 480, 320);
[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setFrame:CGRectMake(0, 0, 480, 320)];

所以一个接一个地尝试

答案 1 :(得分:0)

旋转后设置框架:

playerCtrl.view.frame = CGRectMake(0, 0, 320, 480);