iPhone - Showing video as a splash screen

ε祈祈猫儿з 提交于 2019-12-30 02:29:27

问题


I've the requirement to show video as splash screen in my iphone app I'm using following code:

-(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];}

But the player view is not starting at x=0,y=0 location. What's the reason and how to fix it. Its starting x=100,y=100 (approx).


回答1:


you are setting the information which affects the position three times

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

so try one after another




回答2:


Set frame after rotation:

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


来源:https://stackoverflow.com/questions/4575273/iphone-showing-video-as-a-splash-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!