man*_*urt 5 iphone ipad uiinterfaceorientation autorotate ios
我的启动画面工作正常,但我的应用程序在横向模式下工作,并且启动画面以默认纵向模式显示.
如何启动应用程序以使启动屏幕在我的应用程序之间的横向模式之间旋转?
我正在使用以下代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else {
return NO; }
}
Run Code Online (Sandbox Code Playgroud)
而对于闪屏
-(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];
}
Run Code Online (Sandbox Code Playgroud)
但是如何将旋转放在显示屏内?
@zoul - 到目前为止喜欢这个解决方案。但是,如果/当该视图有任何子视图时 - 它们不会显示。有任何想法吗?
更新:
-startupImageWithOrientation:
通过向在非self.view中创建的 UIView 添加子视图来修复此问题。
- (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];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6969 次 |
最近记录: |