状态栏在运行代码时隐藏

时间:2013-02-10 08:38:57

标签: iphone ios objective-c

出于某种原因,每当我在我的应用程序中运行以下代码时,状态栏都会消失。我在applyaitonLaunchOptions结束时运行,返回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];

}

1 个答案:

答案 0 :(得分:0)

可能是你在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];

因为该行代码隐藏了状态栏