iOS-视图切换|及如何判断view controller是push还是present进去

模态化弹出:(视觉效果进入时:从下到上,出去时从上到下)
present和dismiss对应

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion 
- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^ __nullable)(void))completion
GOVShareViewController *shareViewController = [[GOVShareViewController alloc] initWithArticle:article];
[self presentViewController:shareViewController animated:NO completion:^(void){
                [shareViewController presented];
            }];
[self dismissViewControllerAnimated:YES completion:nil];

推入:(视觉效果是从右向左滑入,出去时从左到右)
pop 和push对应 (根视图是NavigationController,不然是不可以用的)

 [self.navigationController popViewControllerAnimated:NO];
 [self.navigationController pushViewController:pushController animated:animationPush];

用viewController的属性presentingViewController判断是不是模态化弹出

if (self.presentingViewController ! = nil ){
     @"我是模态化弹出";
}

查找资料发现了一篇关于present的文章记录下来

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容