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