在我的代碼中,我正在無限地調用viewWillLayoutSubviews
方法。在viewWillLayoutSubviews
,我重裝這將導致嚴重的內存泄露表導致到屏幕上凍結我的iPad 2致電查看WillLayoutSubviews infintely其中導致屏幕凍結和內存警告
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
if ([APP_DELEGATE popOverIsOpened]) {
[socalMedia dismissView];
[self performSelectorInBackground:@selector(exiBack) withObject:nil];
}
[self.pTableView reloadData];
if (([[UIApplication sharedApplication] statusBarOrientation] ==
UIDeviceOrientationPortrait) ||
([[UIDevice currentDevice] orientation] ==
UIDeviceOrientationPortraitUpsideDown)) {
_pView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
webView.frame = CGRectMake(0, 64, 768, 1024 - 64);
} else {
_pView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
webView.frame = CGRectMake(0, 64, 1024, 768 - 64);
}
CGRect frm = self.navigationController.view.frame;
frm.origin.y = 0;
self.navigationController.view.frame = frm;
}
在什麼情況下,所謂的viewWillLayoutSubviews
方法?它是自動調用還是當方向改變或什麼時候調用?
如果viewWillLayoutSubviews方法在視圖調整大小時調用,那麼爲什麼它會在我的代碼中進入無限調用!最初當渲染視圖時,將會有一個調用,但不是無限的。 – pkc456
嘗試評論此「CGRect frm = self.navigationController.view.frame; frm.origin.y = 0; self.navigationController.view.frame = frm;」 – nikhilgohil11