2015-04-21 26 views
0

我有3個視圖控制器讓VC1-> VC2-> VC3通過導航控制器。在VC3中,我嘗試再次跳回到VC1 &,再次通過進程VC1-> VC2-> VC3進行導航。雖然從一個視圖控制器要等下面的代碼是用來三個視圖控制器的10次跳閘後UI被阻塞

-(void)NEXTButtonpressed:(id)sender 
{ 
    PaymentVC *paymentview=[[PaymentVC alloc] initWithNibName:@"PaymentVC" bundle:Nil]; 

    if (![[[OSEsingleton sharedInstance].globaldictionary objectForKey:@"status"]boolValue]) 
    { 

     if ([self validationforsupportersname]) 
     { 
      [self.navigationController pushViewController:paymentview animated:YES]; 
     } 
    } 
    else 
    { 
     [self.navigationController pushViewController:paymentview animated:YES]; 
    } 
} 

10次後,我的UI被凍結,有時我收到以下錯誤。

1)

levanApp(852,0x366279dc) malloc: *** mach_vm_map(size=65536) failed (error code=3) 
*** error: can't allocate region 
*** set a breakpoint in malloc_error_break to debug 
(Occuring Frequently) 

2)

levanApp[852] <Error>: ImageIO: PNG insufficient memory 
(Occuring Rarely) 

有時應用崩潰並且示出imageWothocontentofFile呼叫在下面的代碼58%的CPU時間

-(UIImage *)returnlogoimgae:(NSString *)imagename 
{ 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *path = [NSString stringWithFormat:@"%@.png",imagename]; 
    NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:path]; 
    NSLog(@"%@",getImagePath); 
    UIImage *image=[UIImage imageWithContentsOfFile:getImagePath]; 
    return image; 
} 

我已經使用時間曲線爲了它。在一個方法調用[_coredata parseTheCoreData:results]我得到100%的CPU時間。我該如何處理這個問題?

+0

可以請你告訴我你的代碼時,點擊或採取任何行動來推動控制器。 –

+0

請查看我更新的代碼nextButtonPressed。 – MuraliMohan

+1

看起來你正在耗盡內存 - 你是否也在爲此進行配置?如果這個假設是正確的,你將需要發佈更多的代碼,因爲你可能會有一個保留週期 – dogsgod

回答

0

看着你的代碼,你好像忘了回去了!這意味着您將所有視圖控制器堆積到堆棧上,直到內存不足。

首先調用

[navigationController popToRootViewControllerAnimated:NO]; 

(使所有推視圖控制器調用非動畫,除了最後一個。)

+0

我正在做同樣的事情。我在第二行提到。 – MuraliMohan

+0

根據發佈的代碼,你沒有這樣做。 – Mundi