- 當在modal時口芍,會把窗口上面的view給移除掉,然后要modal控制器的view給添加到窗口上
- 如果當一個控制器被銷毀,那么它的View的業(yè)務邏輯是無法處理的
- 控制器被銷毀抓艳,控制器的View不一定被銷毀(只要有強指針指向它,就不會被銷毀)
- (IBAction)click:(UIButton *)sender {
#pragma mark 1.系統(tǒng)的modal帚戳,系統(tǒng)在跳轉時控制器不會被銷毀是
因為有一個屬性在強引用控制器self.presentedViewController
NSLog(@"%@",self.presentedViewController);
OneViewController *one = [OneViewController new];
//當在modal時玷或,會把窗口上面的view給移除掉,然后要modal控制器的view給添加到窗口上
// 如果當一個控制器被銷毀片任,那么它的View的業(yè)務邏輯是無法處理的
// 控制器被銷毀偏友,控制器的View不一定被銷毀(只要有槍指針指向它,就不會被銷毀)
// [self presentViewController:one animated:YES completion:^{
//
// NSLog(@"完成了模態(tài)");
//
// }];
#pragma mark 2.自定義的modal
CGRect frame = one.view.frame;
frame.origin.y = [UIScreen mainScreen].bounds.size.height;
one.view.frame = frame;
[[UIApplication sharedApplication].keyWindow addSubview:one.view];
//強引用控制器对供,防止被銷毀
_oneVC = one;
[UIView animateWithDuration:0.5 animations:^{
one.view.frame = self.view.frame;
} completion:^(BOOL finished) {
//[self.view removeFromSuperview];
}];
}
- (IBAction)back:(UIButton *)sender {
#pragma mark 1.系統(tǒng)的modal
//[self dismissViewControllerAnimated:YES completion:nil];
#pragma mark 2.自定義的modal
[UIView animateWithDuration:0.5 animations:^{
CGRect frame = self.view.frame;
frame.origin.y = [UIScreen mainScreen].bounds.size.height;
self.view.frame = frame;
} completion:^(BOOL finished) {
//[[UIApplication sharedApplication].keyWindow addSubview:self.view];
}];
}
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者