当应用程序加载时,我们可以在图像上显示一个按钮吗?

问题描述:

当我们有一个名为Default.png的图像时,它将在应用程序加载时显示。
我们可以在这个图像上有一个按钮,这样,当我们点击按钮时,只有应用程序继续到下一页?当应用程序加载时,我们可以在图像上显示一个按钮吗?

我不这么认为 - 据我所知,这只是一个PNG。

不知道这是你想要的,但我认为它会完成目标。在我的其中一个应用程序中,我在applicationDidFinishLaunching方法中显示了相同的default.png图像,这样我就可以为从该应用程序的主视图转换而来的动画制作动画。如果您只是将一个按钮放在default.png图片上,并在应用完成启动时将其粘贴到视图链的前端,则该按钮应该是无缝的。

这是我的代码是如何开始这一进程设置所有的动画东西之前:

UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)]; 
splashView.image = [UIImage imageNamed:@"Default.png"]; 
[window addSubview:splashView]; 
[window bringSubviewToFront:splashView]; 

此致当然会在那里坚持一个按钮。

我会做什么(并已完成)是添加一个新的UIViewController称为SplashscreenViewController。在SplashscreenViewController.h,改变@interface这样:

@interface SplashscreenViewController : UIViewController { 
} 

- (IBAction)gotorootviewcontroller; 

@end 

在Splashscreenviewcontroller.m,添加以下代码:


- (IBAction)gotorootviewcontroller { 

(your root view controller goes HERE without parentheses) *root = [[(your root view controller goes here without parentheses) alloc] initWithNibName:@"The name of your root view controller goes HERE" bundle:nil]; 
[self presentModalViewController:root animated:YES]; 

} 
- (void)viewDidLoad { 

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default.png"]]; 

} 

在Interface Builder中,添加一个圆角的矩形按钮和连接文件的所有者> gotorootcontroller>按钮>触摸里面。保存并退出,现在你必须做更多的事情。

在MainView.xib中,在检查器的选项选项卡(第1个)中,将NIB名称指向Splashscreenviewcontroller。

这是很多,但它也是最有效的方法来做到这一点!