0

我正在制作一个应用程序,其中我在提供的区域中放置了一个 default.png 并添加sleep(5);到我的应用程序委托中,目前它运行良好。

我需要做的是在应用程序启动时添加多个图像,以便我获得一个启动屏幕 2.5 秒和另一个 2.5 秒。

如何在启动时显示 2 个启动画面?

4

4 回答 4

4

两个闪屏是不可能的。创建一个用 UIImageView 填充第二张图像的 viewcontroller 并显示 2.5 秒。

于 2012-07-31T10:42:19.593 回答
0

只需简单地将您的图像添加到您的视图控制器,然后在 2.5 秒后,将其从您的视图中删除。

于 2012-07-31T10:56:13.330 回答
0

您可以轻松地在主视图之上实现您的视图,但在您的 appDelegate 中。例如,如果您想要一个淡出到主视图的启动图像:(或似乎淡出的默认图像:只需将相同的图像放在启动屏幕和默认屏幕上)。只要它是主视图,这也可以为您提供正确的方向。

只需将其添加到您的

应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:

方法:

UIImageView*imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"your_default_image_or_First.png"]];
[[firstViewController view] addSubview:imageView];
[[firstViewController view] bringSubviewToFront:imageView];
[NSThread SleepForTimeInterval:(2.5)];
[imageView setImage:[UIImage imageNamed:@"your_default_image_or_Second.png"]]
// as usual
[self.window makeKeyAndVisible];

//now fade out splash image
[UIView transitionWithView:self.window duration:1.0f options:UIViewAnimationOptionTransitionNone animations:^(void){imageView.alpha=0.0f;} completion:^(BOOL finished){[imageView removeFromSuperview];}];
于 2016-09-23T12:44:57.090 回答
-3

嗨,请尝试使用以下代码,亲爱的,我建议使用这个代码……

-(BOOL)应用程序:(UIApplication )应用程序didFinishLaunchingWithOptions:(NSDictionary)launchOptions

{

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

// Override point for customization after application launch.

MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil] autorelease];

self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];

UIImageView *imageView = [[[UIImageView alloc] initWithFrame:self.window.bounds] autorelease];

UIImage *image = [UIImage imageNamed:@"Welcome.png"];
if (!image)
{
    NSLog(@"Something went wrong trying to get the UIImage. Check filenames");
}

imageView.image = image;

[self.window addSubview:imageView];
[self.window makeKeyAndVisible];

[self performSelector:@selector(removeFirstSplash:) withObject:imageView afterDelay:3];

return YES;

}

-(void)removeFirstSplash:(UIImageView *)oldImageView

{

UIImageView *imageView = [[[UIImageView alloc] initWithFrame:self.window.bounds] autorelease];

UIImage *image = [UIImage imageNamed:@"Splash.png"];

imageView.image = image;

[self.window addSubview:imageView];

[self performSelector:@selector(removeSecondSplash:) withObject:imageView afterDelay:3];

[oldImageView removeFromSuperview];

}

-(void)removeSecondSplash:(UIImageView *)oldImageView

{

[self.window addSubview:self.navigationController.view];

[oldImageView removeFromSuperview];

}

于 2012-07-31T11:01:15.943 回答