我有重大的內存管理問題。在小程序使用後,它會崩潰內存不足。我終於找到了原因,每次創建新的ViewController而不是訪問實例時,我都會創建一個新的實例。內存管理 - 如何在不創建新實例的情況下顯示已經實例化的ViewController
因此,應用程序加載並實例化FirstViewController。您單擊一個實例化FilterViewController
的按鈕。從這裏的時候回到FirstViewController
我創造的這個新例如如下:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName
:@"MainStoryboard" bundle:nil];
FirstViewController *fvc = [storyboard
instantiateViewControllerWithIdentifier:@"FirstViewController"];
fvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
,並重復過程。任何呈現視圖控制器而不重新實例化的方式?我接近提交應用程序(希望明天),所以我需要嘗試得到這個排序。謝謝!
這裏是ViewController的介紹。
[self presentViewController:fvc animated:YES completion:nil];
呈現FilterViewController
從FirstViewController
- (IBAction)searchOptions:(id)sender {
FilterViewController *ctrl = [[FilterViewController alloc] init];
[UIView transitionFromView:self.view toView:ctrl.view duration:1 options:UIViewAnimationOptionTransitionCurlUp completion:nil];
self.filterViewController = ctrl;
[self.navigationController pushViewController:self.filterViewController animated:NO];
}
嘿謝謝你。所以我把這段代碼放在'[self dismissViewControllerAnimated:YES completion:^ {NSLog(@「test」); }];'但是它不會返回或添加NSLog。我已經去了我的'FirstViewController',它有這樣一行:'[self.navigationController pushViewController:self.filterViewController animated:NO];'所以我應該嘗試彈出它? –
試圖彈出它,但它什麼都不做,試過'popToRootViewControllerAnimated'也沒有做任何事 –
你在過濾視圖控制器的方法中添加了彈出代碼?你可以展示如何創建和顯示原始控制器的代碼。 – Wain