vc切換到vc總結

一、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的viewbash

//    [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];
        }];
    }];
複製代碼

二、 多級vc present

vc present vc1 vc1 present vc2 vc2 present vc3 vc dimiss 什麼現象? vc2,vc3, 同時dealloc,頁面直接回到第一個 vcapp

三、vc 屢次 dimiss

vc present vc1 vc1 dismiss vc1 dimiss vc1 dimiss 重複調用dimiss 什麼現象? 只有第一個vc1 dimiss有效,其它的無做用;只有第一個vc的dimiss completion block執行,後面的dimiss completion block不會調用ide

//    [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__);
            }];
        }];
    }];
複製代碼

四、不一樣vc之間的 present

navvc present: tabvc,vc,navvc tabvc present: tabvc,vc,navvc vc present: tabvc,vc,navvc 都是OK的ui

五、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:支持!!!this

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. 不會!spa

七、present vc以後, 舊的vc不會dealloc

vc present vc1, vc1 present vc2, vc2 present vc3 全部舊的vc都不會dealloc 由於一層一層被root vc持有, root vc持有childvc方式、或者presented的方式code

八、vc1進入vc2

vc2回到vc1rem

push進入或者pop返回 vc1 willDisappear -〉 vc2 willAppear -》vc1 DidDisappear -〉 vc2 DidAppearstring

present進入或dimiss返回 vc1 willDisappear -〉 vc2 willAppear -》vc2 DidAppear -〉vc1 DidDisappearit

對vc presentedViewController/presentingViewController 的影響 對navvc viewControllers的影響

相關文章
相關標籤/搜索