iOS

iOS - 基类的返回方法

2018-11-30  本文已影响30人  神灬渐入嘉靜

根据当前ViewController是push还是present方式显示的返回不同的back方式达到actionBack方法全统一

 - (void)actionBack
{
    //方式一
    if (self.presentingViewController) {
        [self dismissViewControllerAnimated:YES completion:nil];
    } else {
        [self.navigationController popViewControllerAnimated:YES];
    }

    /*
    //方式二
    if (self.navigationController.topViewController == self) {
        [self.navigationController popViewControllerAnimated:YES];
    } else {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
     */
}
上一篇 下一篇

猜你喜欢

热点阅读