gpt4 book ai didi

ios - 为什么我的 ModalView 以纵向模式显示?

转载 作者:行者123 更新时间:2023-11-29 04:55:30 26 4
gpt4 key购买 nike

希望有人能指出我的启动屏幕做错了什么。问题是屏幕以纵向模式显示,而不是横向模式......

- (void)showSplash
{
UIView *modelView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024 , 748)];

UIViewController *modalViewController = [[UIViewController alloc] init];
[modelView setBackgroundColor:[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"Splash.png"]]];

modalViewController.view = modelView;

[self presentModalViewController:modalViewController animated:NO];


[self performSelector:@selector(hideSplash) withObject:nil afterDelay:5.0];

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

预先感谢您的帮助。

最佳答案

看起来您正在为 iPad 编写应用程序。如果是这样,你必须同时支持横向和纵向,否则苹果会拒绝它。我建议您应该使用两个不同的图像。图片规范如下:

  1. 默认景观.png (1004 * 768)
  2. 默认肖像.png (748*1024)

(我假设如果不向图像高度添加 20 像素,您将显示状态栏)

就是这样,创建这些图像并将其添加到您的项目中。你就可以走了。也不需要编写任何额外的代码..

你成功了

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

关于ios - 为什么我的 ModalView 以纵向模式显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8070701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com