#import "ViewController.h"
#import "TwoViewController.h"
@interface ViewController ()
@property (nonatomic, strong) TwoViewController *twoVC;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor redColor];
}
- (IBAction)modal:(id)sender {
/***
1.modal出控制器的View是添加到哪里的?
把之前窗口的根控制器的view,从窗口上移除.
modal出控制器的View是添加到窗口上的
2.modal出控制器要不要强引用?如果要的话, 是谁强引用?
必须得要有人强引用.
是有self.presentedViewController
3.如果一个控制器没有强引用, 会造成什么问题?
如果一个控制器没有强引用,那么该控制器下的所有业务逻辑都没有效果(所有写的代码都不执行了);
*/
// CGFloat width = [UIScreen mainScreen].bounds.size.width;
// CGFloat height = [UIScreen mainScreen].bounds.size.height;
//
TwoViewController *twoVC = [[TwoViewController alloc] init];
// self.twoVC = twoVC;
// twoVC.view.frame = CGRectMake(0, height, width, height);
// [UIView animateWithDuration:0.5 animations:^{
// CGRect frame = twoVC.view.frame;
// frame.origin.y = 0;
// twoVC.view.frame = frame;
// }];
//
//
// [[UIApplication sharedApplication].keyWindow addSubview:twoVC.view];
NSLog(@"%@",self.presentedViewController);
[self presentViewController:twoVC animated:YES completion:^{
//NSLog(@"%@",[UIApplication sharedApplication].keyWindow.rootViewController);
NSLog(@"%@",self.presentedViewController);
}];
}
- (void)dealloc {
NSLog(@"%s",__func__);
}
网友评论