【问题标题】:Multiple Launch image of iOSiOS的多次启动图像
【发布时间】:2013-05-15 20:40:20
【问题描述】:

我的应用有一个条款和条件页面。应用安装后第一次可见。接受条款后,它永远不会向用户显示。

我为第一页制作了启动图像,而不是为条款页制作了启动图像。但是在应用安装后第一次应该不是标准的。

  1. 那么如何根据条件使用 2 个启动图像?

  2. 如果我只为我的应用程序(iPhone 和 iPad)设置纵向模式,Apple 会拒绝吗?

【问题讨论】:

  • 首次显示,在AppDelegate方法applicationDidFinishLaunching中写代码
  • 怎么可能,我知道以编程方式更改启动图像是不可能的。请解释..
  • Nguyen Duc 所说,为您的 2 张图片创建单独的 UIViewController,然后使用常规 Root UIViewController

标签: ios image launch


【解决方案1】:

我是这样解决的:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    // ... stuff

    if( [defaults objectForKey:@"GTCAccepted"] )
    {
        [self performSelector:@selector(gtcAccepted)]; //
    }
    else
    {
        GTCViewController* gtcViewController; // where GTCViewController is a normal UIViewController

        //universal app
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
            gtcViewController = [[GTCViewController alloc] initWithNibName:@"GTCViewController-iPad" bundle:nil];
        else
            gtcViewController = [[GTCViewController alloc] initWithNibName:@"GTCViewController" bundle:nil];

        [window setRootViewController:gtcViewController]; // also can show as modal VC
        [gtcViewController release];

        // if accepted, set [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"GTCAccepted"]; in the GTCViewController
    }
}

还有你的 2 张启动图片...

接受 GTC 后尝试此代码

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"GTCAccepted"];

NSURL *path2 = [[NSBundle mainBundle] URLForResource:@"Default-568h@2x_2" withExtension:@"png"];
NSURL *path = [[NSBundle mainBundle] URLForResource:@"Default-568h@2x" withExtension:@"png"];

[[NSFileManager defaultManager] removeItemAtURL:path error:nil]; // permission denied

if([[NSFileManager defaultManager] copyItemAtURL:path2 toURL:path error:nil])
{
    NSLog(@"startItem replaced!");
}else
{
    NSLog(@"oh oh... item not replaced!");
}

更新:
代码在设备上不起作用,查看权限在删除时被拒绝

顺便说一句,如果你总是在从 Xcode 开始的模拟器上运行,你会在每次运行时覆盖它。并且在这里您没有机会在应用启动之前更改图像。

【讨论】:

  • 谢谢!但是当我们使用 Default-568h@2x 作为启动图像时,将如何调用 Default-568h@2x_2。我需要更换所有尺寸的启动图像。请告诉我你的想法。
  • 您将 Default-568h@2x_2 作为简单图像添加到您的目标中,就像所有其他分辨率一样(希望您知道如何将现有文件添加到您的项目中:P)。如果图像在您的捆绑包中,则您可以完全访问它。如果您需要全部替换,请随意这样做^^只需复制粘贴上半部分或循环它们,这是您的决定:)
  • 您是否在设备中检查过这个并且 Apple 也批准了这个?
  • 我不认为苹果会拒绝这个(值得一试:P)但我只是在设备上尝试了这个理论,我得到了“权限被拒绝”:/太糟糕了,现在它只剩下改变背景而不是启动屏幕:(
  • 那么这不是标记答案。
【解决方案2】:
  1. 我认为你不应该使用 2 启动图像。如果要根据条件检查图像,可以使用视图控制器显示、动画并转到下一个屏幕。启动图像只有一个。我们无法访问它。
  2. 仅适用于 iPhone 和 iPad 的肖像不会被拒绝。

【讨论】:

  • 谢谢! ,您是说每次应用程序都会显示第一个屏幕而不是术语屏幕。如果安装后第一次,应用程序会通过动画从第一个屏幕导航到术语屏幕吗?请告诉我详情。
  • 在你的项目中只有一个启动图像说 LaunchImage@3x.png 可以吗,苹果会因为没有提供其他配置图像而拒绝我的应用程序,我想做的原因是因为我的图像大约 25 KB。
猜你喜欢
  • 1970-01-01
  • 2013-06-20
  • 2014-07-09
  • 1970-01-01
  • 2015-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-14
相关资源
最近更新 更多