2012-11-21 165 views
1

最近我遇到了一個問題,我的應用程序在初次啓動時進入後臺,但這隻發生在iOS4的iPhone 4S上。我已經進行了測試:iPhone - 在應用程序啓動過程中,應用程序進入背景

  • 模擬器,具有不同的硬件/軟件配置
  • iPhone 5(的iOS 6)
  • iPhone 4S(的iOS 5.1)
  • 的iPad2(iOS 6中)

並且它們都在使用它們,但是在iOS6的iPhone 4S上,應用程序的啓動在進入後臺之前大約需要20秒,如果您在幾秒鐘後「重新啓動」應用程序,您會發現它仍然存在運行和工作沒有任何問題。

是否有任何知道iPhone4S(iOS6)的問題,導致這種情況或有什麼特別的這種模式? [我已經測試了不同的iPhone4s(iOS6的),它是發生在所有的人]

編輯

我發現了一些奇怪的意願做一些更多的測試,iPhone 4S(iOS6的)是唯一一個不顯示加載屏幕(第一視圖控制器),它只顯示啓動圖像。不管怎麼樣,這裏是在AppDelegate中和第一視圖控制器代碼:

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 
    // Optional: automatically track uncaught exceptions with Google Analytics. 
    [GAI sharedInstance].trackUncaughtExceptions = YES; 
    // Optional: set Google Analytics dispatch interval to e.g. 20 seconds. 
    [GAI sharedInstance].dispatchInterval = 20; 
    // Optional: set debug to YES for extra debugging information. 
    [GAI sharedInstance].debug = NO; 
    // Create tracker instance. 
    __unused id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-APP-ID"]; 
    return YES; 
} 

EcraPrincipalViewController.m

#import "EcraPrincipalViewController.h" 
#import "ListaPercursosTableViewController.h" 
#import "GlobalVars.h" 
#import "AppDelegate.h" 

@interface EcraPrincipalViewController() 

@end 

@implementation EcraPrincipalViewController 
{ 
    int progresso; 
    int sizePercursos; 
} 

@synthesize lbl_versao; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.trackedViewName = @"iPhone - EcrãPrincipal"; 
    // Do any additional setup after loading the view. 

    NSMutableArray *views = [[NSMutableArray alloc] initWithArray:[self.navigationController viewControllers]]; 
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"WalkMeStoryBoard" bundle:nil]; 
    ListaPercursosTableViewController *listaV = [story instantiateViewControllerWithIdentifier:@"view_lista"]; 
    [views replaceObjectAtIndex:0 withObject:listaV]; 
    [self.navigationController setViewControllers:views]; 

    lbl_info.text = NSLocalizedString(@"downloading", NULL); 
    lbl_versao.text = NSLocalizedString(@"walkme_versao", NULL); 

    dispatch_queue_t queue = dispatch_queue_create("com.WalkMe.downloadPercursos", NULL); 
    dispatch_async(queue, ^{ 
     [[GlobalVars Instance] getLevadas:self]; 
    }); 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

- (BOOL)shouldAutorotate 
{ 
    return [[GlobalVars Instance] podeRodar]; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

-(void)novaAtualizacao 
{ 
    NSLog(@"Atualização encontrada"); 
    lbl_info.text = NSLocalizedString(@"atualizacao_encontrada", NULL); 
} 
-(void)atualizarPercursosInternos 
{ 
    NSLog(@"VERIFICAÇAO Interna"); 
    lbl_info.text = NSLocalizedString(@"a_atualizar_percursos", NULL); 
} 
-(void)setNewDownload:(NSNumber*)size 
{ 
    NSLog(@"Iniciou VERIFICAÇAO"); 
    progresso = 0; 
    sizePercursos = [size intValue]; 
    lbl_info.text = [NSString stringWithFormat:@"%@ 0/%d", NSLocalizedString(@"novos_percursos", NULL), sizePercursos]; 
} 
-(void)setProgress 
{ 
    NSLog(@"Progresso"); 
    progresso++; 
    lbl_info.text = [NSString stringWithFormat:@"%@ %d/%d", NSLocalizedString(@"novos_percursos", NULL), progresso, sizePercursos]; 
} 
-(void)goToLista 
{ 
    NSLog(@"ACABOU VERIFICAÇAO"); 

    UIStoryboard *story = [UIStoryboard storyboardWithName:@"WalkMeStoryBoard" bundle:nil]; 
    [[GlobalVars Instance] getLevadas]; 
    [self.navigationController pushViewController:[story instantiateViewControllerWithIdentifier:@"view_lista"] animated:NO]; 
} 

- (void)viewDidUnload { 
    [self setLbl_versao:nil]; 
    [super viewDidUnload]; 
} 
@end 

非常感謝您對我們的關注和幫助:)

+0

控制檯給你提示嗎? –

+0

根本沒有,如果一切正常運行,保持空白 –

+0

你可以發佈你的'application:didFinishLaunchingWithOptions:'和你的任何啓動方法從第一個視圖控制器(如'viewDidLoad') –

回答

0

雖然試圖弄清楚發生了什麼事情,在意見的問題提出的建議讓我意識到由於某種原因,應用程序調用了相同的方法兩次,並由於某種原因導致應用程序轉到後臺。

爲了解決這個問題,簡單地從viewDidLoad中

NSMutableArray *views = [[NSMutableArray alloc] initWithArray:[self.navigationController viewControllers]]; 
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"WalkMeStoryBoard" bundle:nil]; 
    ListaPercursosTableViewController *listaV = [story instantiateViewControllerWithIdentifier:@"view_lista"]; 
    [views replaceObjectAtIndex:0 withObject:listaV]; 
    [self.navigationController setViewControllers:views]; 

刪除此行並將其添加到goToLista(初始加載完成後,這就是所謂的)。

我結束了:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.trackedViewName = @"iPhone - EcrãPrincipal"; 
    // Do any additional setup after loading the view. 

    lbl_info.text = NSLocalizedString(@"downloading", NULL); 
    lbl_versao.text = NSLocalizedString(@"walkme_versao", NULL); 

    dispatch_queue_t queue = dispatch_queue_create("com.WalkMe.downloadPercursos", NULL); 
    dispatch_async(queue, ^{ 
     [[GlobalVars Instance] getLevadas:self]; 
    }); 
} 

-(void)goToLista 
{ 
    NSLog(@"ACABOU VERIFICAÇAO"); 

    [[GlobalVars Instance] getLevadas]; 

    NSMutableArray *views = [[NSMutableArray alloc] initWithArray:[self.navigationController viewControllers]]; 
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"WalkMeStoryBoard" bundle:nil]; 
    ListaPercursosTableViewController *listaV = [story instantiateViewControllerWithIdentifier:@"view_lista"]; 
    [views replaceObjectAtIndex:0 withObject:listaV]; 
    [self.navigationController setViewControllers:views]; 
    [self.navigationController pushViewController:[story instantiateViewControllerWithIdentifier:@"view_lista"] animated:NO]; 
} 

這解決了問題,但我不知道爲什麼。如果有人知道,請告訴,因爲我真的很想知道。

謝謝:)

相關問題