我需要帮助才能在iphone上启动图像。 在xcode的项目设置中,有一个添加启动图像的选项。 我添加它并显示2秒钟...... 我希望它更多...... 我怎么能改变它? 谢谢:))
答案 0 :(得分:18)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
/*this will pause main thread for x interval seconds.
put on the top of application:didFinishLaunchingWithOptions, so it will not
proceed to show window until sleep interval is finished.*/
[NSThread sleepForTimeInterval:2]; //add 2 seconds longer.
//other code....
}
答案 1 :(得分:12)
您也可以通过在
中应用以下代码来完成此操作 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
[NSThread sleepForTimeInterval:2.0]; // Used For Showing Splash Screen for More Time
}
首先创建viewcontroller,将图像设置为启动画面/ Launc图像..
在方法applicationDidFinishLaunching中显示该视图: 使用动画:否
并在您的演示
的另一个视图中写下以下代码-(void) viewWillAppear:(BOOL)animated
{
[self performSelector:@selector(dismiss1) withObject:nil afterDelay:5.0f];
[super viewWillAppear:animated];
}
-(void) dismiss1
{
[self dismissModalViewControllerAnimated:NO];
}
如果您想在每次应用打开时显示启动画面,请在applicationDidBecomeActive方法中显示启动画面视图控制器
答案 2 :(得分:2)
您可以使用sleep()
方法。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
sleep(10);
return YES;
}
答案 3 :(得分:1)
启动图像是为了让您的应用显示真正的响应,并且应该是您的UI之前的任何项目的快照,如tabBars等.Apple并不真的希望您将它们用作启动画面。
也就是说,很多人都会这样做,并且要实现这一结果,您的应用代表需要在启动图片时在屏幕上显示相同的图片,然后您可以延迟使用performSelector:withObject:afterDelay:
启动主应用
答案 4 :(得分:1)
在Swift中
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Thread.sleep(forTimeInterval: 2.0)
return true
}
答案 5 :(得分:0)
制作默认视图...使用相同的默认图片制作图片视图...然后使用[self performselector methods
答案 6 :(得分:0)
您可以在第一个加载的视图中放置UIImageView。比如,在FirstViewController的viewDidLoad中
-(void)viewDidLoad{
appLogo = [UIImageView alloc]initWithImage:[UIImage imageNamed:@"companyLogo.png"]];
[appLogo setFrame:CGRectMake..... ];
self.view addSubView:appLogo];
[self performSelector:@selector(hideAppLogo) withObject:nil afterDelay:1000000 :) ];
}
-(void)hideAppLogo{
[appLogo setHidden:YES];
//let the user use your app now!
}
答案 7 :(得分:0)
你可以通过在将窗口分配给rootviewController之前在窗口中添加“Default.png”的backgroundColor来实现这一点,并在几秒钟之后将rootviewController分配给窗口并将窗口背景颜色设置为默认值。
像这样 -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self performSelector:@selector(openLoginScreen) withObject:nil afterDelay:0.5];
self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default.png"]];
[self.window makeKeyAndVisible];
}
-(void)openLoginScreen{
self.window = [UINavigation .... "YOUR ROOT VIEWCONTROLLER"];
}