0
是否可以在iOS中回收/強制銷燬UIViewController
?問:如何強制銷燬iOS中的視圖控制器?
我用這github project得到一個定製UIViewControllerTransition
:
這裏是程序的流程:
vc1
禮物給nav
到的rootVc
是vc2
- 在
vc2
有是UIButton
。點擊後,vc2
的NavigatioCcontroller
將被解僱。
但問題是,vc2
不是由OS回收,所以當我進展爲vc1
,然後呈現給nav
(這rootVc
是vc2
),vc2
不調用viewDidLoad
方法。
不知道問題出在哪裏。有沒有辦法讓我點擊vc2
的UIButton
,強制銷燬nav
和vc2
?這樣,當我再次出現到nav
時,vc2
的viewDidload
將再次被調用。
代碼:
在vc1
:
LMLQQSearchSelectViewController *search_vc = [[LMLQQSearchSelectViewController alloc] initWithNibName:@"LMLQQSearchSelectViewController" bundle:nil];
search_vc.fromController = @"KnowledgeViewController";
search_vc.pre_type = @"ENCYCLOPEDIACOL";
LMLQQSearchNavController *nav = [[LMLQQSearchNavController alloc] initWithRootViewController:search_vc];
nav.navigationBarHidden = YES;
__weak typeof(self) weakSelf = self;
_search_header.block = ^(){
weakSelf.transition = [[HYBEaseInOutTransition alloc] initWithPresented:^(UIViewController *presented, UIViewController *presenting, UIViewController *source, HYBBaseTransition *transition) {
HYBEaseInOutTransition *modal = (HYBEaseInOutTransition *)transition;
// If you don't specify, it will use default value
// Default is NO, if set to YES, it will use spring animation.
modal.animatedWithSpring = NO;
} dismissed:^(UIViewController *dismissed, HYBBaseTransition *transition) {
// do nothing
}];
nav.transitioningDelegate = weakSelf.transition;
[weakSelf presentViewController:nav animated:YES completion:NULL];
};
我想到了'option 2',它會在我的項目中造成一些麻煩,我會在選項1中進行測試,你的意思是在方法中:'[self.navigationController dismissViewControllerAnimated:YES completion:^ { //重置root vc? }];' – aircraft