2011-09-14 1 views
3

起動時に、アプリがアップデートを確認します。それが利用可能であるならば、私はこの命令で互いの上にオーバーレイビューを配置しよう:keyWindow上のオーバーレイビューがすばやく消えます(iOS)

[[[UIApplication sharedApplication] keyWindow] addSubview:overlay]; 

私は更新処理が終了したときに、それを削除する一方、オーバーレイビューは、表示されますが、すぐに消えます。代わりに、現在のビューのサブビューとしてオーバーレイビューを追加すると、オーバーレイビューは更新プロセスが終了するまでその上にとどまります。

私のアプリケーションにはタブバーがあるので、オーバーレイビューを配置する必要があります。オーバーレイビューを現在のビューの上に置くと、ユーザーが別のアイテムをタップするとオーバーレイビューが消えます。タブバー。

NSInvocationを使用して別のタスクで更新の確認を行ったことが原因である可能性がありますか?ここに私の関連するコードです:

[のviewDidLoad中] [は、checkForUpdate中]

NSOperationQueue *queue = [NSOperationQueue new]; 

    NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(checkForUpdate) object:nil]; 

    [queue addOperation:operation]; 
    [operation release]; 

[はdoupdate中]
if (![localVersion isEqualToString:remoteVersion]) 
    { 
     [self performSelectorOnMainThread:@selector(doUpdate) withObject:nil waitUntilDone:NO]; 
    } 

[willDismissWithButtonIndex中]

UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Update" message:@"Download the latest version of...?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 

[alertView show]; 
[alertView release]; 

if (buttonIndex == 1) 
{ 
    CGRect overlayFrame = [[UIApplication sharedApplication] keyWindow].bounds; 
    overlay = [[UIView alloc] initWithFrame:overlayFrame]; 
    overlay.backgroundColor = [UIColor blackColor]; 
    overlay.alpha = 0.7; 

    // Do other staff... 

    [[[UIApplication sharedApplication] keyWindow] addSubview:overlay]; 

    NSURL *url = [NSURL URLWithString:@"http:www.testserver.com/test/UpdatePack.zip"]; 
    NSURLRequest *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:300.0]; 

    connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 
    connection = nil; 
} 

[connectionDidFinishLoading中]

[overlay removeFromSuperview]; 

答えて

3

私はtabbarViewControllerのビューにオーバーレイを追加し、問題を解決:

[self.tabBarController.view addSubview:overlay]; 
関連する問題