1、vc present 多个vc
vc present vc1
vc present vc2
vc present vc3
什么现象?
2019-07-03 13:20:50.876200+0800 vcpresentTest[3214:42279] Warning: Attempt to present <ViewController: 0x7fe27c510d70> on <duogepresentAndDimissFirstVc: 0x7fe27c5081e0> whose view is not in the window hierarchy!
vc的view不再window上 不能再present 别的vc了,只有得一个vc的present 的completion block调用,后面的completion block不会调用
最终页面显示vc1的view
// [self presentViewController:vc1 animated:YES completion:nil];
// [self presentViewController:vc2 animated:YES completion:nil];
// [self presentViewController:vc3 animated:YES completion:nil];
[self presentViewController:vc1 animated:YES completion:^{
[self presentViewController:vc2 animated:YES completion:^{
//completion不会执行
[self presentViewController:vc3 animated:YES completion:nil];
}];
}];
2、 多级vc present
vc present vc1
vc1 present vc2
vc2 present vc3
vc dimiss
什么现象?
vc2,vc3, 同时dealloc,页面直接回到第一个 vc
3、vc 多次 dimiss
vc present vc1
vc1 dismiss
vc1 dimiss
vc1 dimiss
重复调用dimiss 什么现象?
只有第一个vc1 dimiss有效,其它的无作用;只有第一个vc的dimiss completion block执行,后面的dimiss completion block不会调用
// [self dismissViewControllerAnimated:YES completion:nil];
// [self dismissViewControllerAnimated:YES completion:nil];
// [self dismissViewControllerAnimated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:^{
[self dismissViewControllerAnimated:YES completion:^{
//completion不会执行
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"%s[%d]", __func__, __LINE__);
}];
}];
}];
4、不同vc之间的 present
navvc present: tabvc,vc,navvc
tabvc present: tabvc,vc,navvc
vc present: tabvc,vc,navvc
都是OK的
5、push
navvc push: tabvc,vc,navvc
push navvc:崩溃
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
push tabvc:支持!!!
6,push 或者 present 不会改变window的rootviewcontroller
The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller’s view as the content view of the window. The new content view is configured to track the window size, changing as the window size changes. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.
The default value of this property is nil.
不会!
7、present vc之后, 旧的vc不会dealloc
vc present vc1, vc1 present vc2, vc2 present vc3 所有旧的vc都不会dealloc
因为一层一层被root vc持有, root vc持有childvc方式、或者presented的方式
网友评论