如何在iOS上旋转自定义初始屏幕? [英] How do I rotate custom splash screen on iOS?
问题描述
我的启动画面工作正常,但我的应用程序在横向模式下工作,启动画面以默认纵向模式显示。
My splash screen is working, but my app works on landscape mode, and the splash screen shows in the default portrait mode.
如何启动应用程序以便启动画面在像我的应用程序这样的横向模式之间旋转?
How can I start the app so that the splash screen rotates between landscape modes like my app?
我正在使用以下代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else {
return NO; }
}
和启动画面
-(void)displayScreen {
UIViewController *displayViewController=[[UIViewController alloc] init];
displayViewController.view = displaySplashScreen;
[self presentModalViewController:displayViewController animated:NO];
[self performSelector:@selector(removeScreen) withObject:nil afterDelay:3.0];
}
-(void)removeScreen
{ [[self modalViewController] dismissModalViewControllerAnimated:YES];
}
但是如何将旋转放在显示屏内?
But how can I put the rotate inside the display screen?
推荐答案
@zoul - 到目前为止爱这个解决方案。但是,如果/当该视图有任何子视图时 - 它们不会显示。任何想法?
@zoul - loving this solution so far. however, if/when that view has any subviews - they don't show up. any ideas?
更新:
通过在<$ c中创建的UIView添加子视图解决了这个问题$ c> -startupImageWithOrientation: 不 self.view。
fixed this issue by adding a subview to the UIView created in -startupImageWithOrientation:
not self.view.
- (UIView *)startupImageWithOrientation:(UIInterfaceOrientation)io{
UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"Default-%@.png", UIInterfaceOrientationName(io)]];
UIView *aView = [[UIImageView alloc] initWithImage:img];
[aView setFrame:[[UIScreen mainScreen] applicationFrame]];
// define the version number label
self.versionNumberLabel_iPadSplashScreen.text = [NSString stringWithFormat:@"Version %@",
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
[aView addSubview:self.versionNumberLabel_iPadSplashScreen];
return [aView autorelease];
}
这篇关于如何在iOS上旋转自定义初始屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!