如何设置启动屏幕的确切时间并在 iPhone 查询中启动时加载?
Posted
技术标签:
【中文标题】如何设置启动屏幕的确切时间并在 iPhone 查询中启动时加载?【英文标题】:How to set exact time for splash screen with loading on launch in iPhone query? 【发布时间】:2012-01-31 07:19:50 【问题描述】:在我的地图应用程序中,我在 ViewDidLoad 方法中调用了 Web 服务方法。因此我的 如果网络很差,无法在我的第一个屏幕 MapView 上加载 Web 服务数据,则启动屏幕显示时间更长(超过 5 秒)。
我想只显示 Default.png 3 秒,然后我的第一个屏幕显示加载指示器,例如 最近在 iPHone 上的 facebook 应用程序。该应用程序背后的逻辑是什么。我尝试了很多东西,但还没有成功。提前致谢。
【问题讨论】:
***.com/questions/2254351/iphone-splash-screen 【参考方案1】:You will need to use performSelector: withDelay: method and provide the delay to 3-4 seconds, whatever is desired. NSTimer will also work but perfomSelector is a more lighter approach.
Try using it in the function where you allocate the splash image. In this case as u said u need to call from ViewDidLoad another function something like performSelector:removeSplashScreen and put this in [self performSelector:removeSplashScreen afterDelay:4 withObject:imgSplash];
THis will call the removeSplashScreen after 4 seconds and hence pass the splash image as parameter to this function.
Inside removeSplashScreen do something like this:
-(void)removeSplashScreen:(UIImageView*)imgSplash
//remove splash hence 4 seconds have passed.
[imgSplash removeFromSupreview];
[imgSplash release];
//After this allocate UIActivityIndicator view or whatever custom view for further loading
//You can also call an NSURLConnection here for the data parsing as the splash has been //removed thereby showing an activity to user.
//hope this helps :)
【讨论】:
【参考方案2】:使用 NSTimer 实现此功能。
【讨论】:
【参考方案3】:首先你把default.png然后
然后像下面的代码一样添加简单的视图控制器
[window addSubview:viewController.view];
您可以在其中添加要放置的活动指标。
然后当 Internet 连接完成然后调用委托方法
-(void)ShowTabAbout
[viewController.view removeFromSuperview];
self.imgV.frame=CGRectMake(0, 425, 320, 55);
self.imgV.image=[UIImage imageNamed:@"tBar5.png"];
[self.tabctr.view addSubview:self.imgV];
self.tabctr.selectedIndex=4;
[self animationTabCode];
[window addSubview:tabctr.view];
下面是动画的代码
-(void)animationTabCode
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.window cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
[UIView commitAnimations];
这种类型的你可以很聪明地创建应用程序
【讨论】:
感谢您的回答。如果我有时间,我会大胆尝试。现在我使用了带有 timedelay 的 performSelector 方法以上是关于如何设置启动屏幕的确切时间并在 iPhone 查询中启动时加载?的主要内容,如果未能解决你的问题,请参考以下文章
Gatsby + Contentful - 如何在不重新启动服务器的情况下在本地重做 GraphQL 查询(npm run dev)?
每当我使用 `npm start` 启动我的应用程序时,它会将我带到 Ruby on Rails 主屏幕,而不是我的 index.html 文件