状态栏隐藏时运行代码

问题描述:

由于某些原因,每当我在我的应用程序中运行下面的代码时,状态栏消失。我在applicationaitonLaunchOptions结尾处运行,上面返回YES。状态栏隐藏时运行代码

有谁知道为什么会发生这种情况?

下面的代码询问人们是否要升级到新的应用程序版本。

NSString * version = @""; 
NSString * nstri = [NSString stringWithFormat: @"http://itunes.apple.com/lookup?id=%@", APPID]; 
NSURL *url = [NSURL URLWithString: nstri]; 

ASIFormDataRequest * versionRequest = [ASIFormDataRequest requestWithURL:url]; 

[versionRequest setRequestMethod:@"GET"]; 
[versionRequest setDelegate:self]; 
[versionRequest setTimeOutSeconds:150]; 
[versionRequest addRequestHeader:@"Content-Type" value:@"application/json"]; 
[versionRequest startSynchronous]; 

//Response string of our REST call 
NSString* jsonResponseString = [versionRequest responseString]; 

NSDictionary *loginAuthenticationResponse = [jsonResponseString objectFromJSONString]; 

NSArray *configData = [loginAuthenticationResponse valueForKey:@"results"]; 

for (id config in configData) 
{ 
    version = [config valueForKey:@"version"]; 
} 

NSLog(@"app version: %@", version); 

//Check your version with the version in app store 
if (![version isEqualToString: APPVERSION]) 
{ 
    UIAlertView *createUserResponseAlert = [[UIAlertView alloc] initWithTitle:@"New Version!" message: @"A new version of Handybook app is available to download. Please update your app for the latest features." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: @"Download", nil]; 
    [createUserResponseAlert show]; 

} 
+4

请不要在主线上做同步联网!这让我哭。 – 2013-02-10 08:40:03

这可能是因为你有这样的代码在你的AppDeleget.m在:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *) launchOptions { 
    [[UIApplication sharedApplication] setStatusBarHidden:YES with Animation:NO]; 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
} 

时是在放出来:

[[UIApplication sharedApplication] setStatusBarHidden:YES with Animation:NO]; 

,因为该行代码隐藏状态吧