- (IBAction)click:(UIButton *)sender {
#pragma mark 1.系统的modal,系统在跳转时控制器不会被销毁是
因为有一个属性在强引用控制器self.presentedViewController
NSLog(@"%@",self.presentedViewController);
OneViewController *one = [OneViewController new];
//当在modal时,会把窗口上面的view给移除掉,然后要modal控制器的view给添加到窗口上
// 如果当一个控制器被销毁,那么它的View的业务逻辑是无法处理的
// 控制器被销毁,控制器的View不一定被销毁(只要有枪指针指向它,就不会被销毁)
// [self presentViewController:one animated:YES completion:^{
//
// NSLog(@"完成了模态");
//
// }];
#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];
}];
}