Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更灵活的popViewController #14

Open
xaoxuu opened this issue May 7, 2017 · 0 comments
Open

更灵活的popViewController #14

xaoxuu opened this issue May 7, 2017 · 0 comments

Comments

@xaoxuu
Copy link
Owner

xaoxuu commented May 7, 2017

有时候想pop到从RootVC开始数的第二个VC怎么办?虽然实现并不复杂,但是这些可自动化的工作能封装起来用着自然舒服很多。
于是我封装了两个更灵活的pop方法:

/**
 pop到指定viewController

 @param index 从rootVC开始向后数的index,rootVC为0
 */
- (void)ax_popToViewControllerWithIndexFromRoot:(NSUInteger)index;

/**
 pop到指定viewController

 @param index 从当前viewController开始向前数的index,当前VC为0
 */
- (void)ax_popToViewControllerWithIndexFromSelf:(NSUInteger)index;

使用示例:
我在一个view里放置了两列按钮,一列是从RootVC开始数index,另一列是反向从当前VC开始数index。

- (IBAction)popFromRoot:(UIButton *)sender {
    [self.controller.navigationController ax_popToViewControllerWithIndexFromRoot:sender.titleLabel.text.integerValue];
    // 传入参数为几,就pop到从rootVC开始向下数的第几层VC。
}
- (IBAction)popFromSelf:(UIButton *)sender {
    [self.controller.navigationController ax_popToViewControllerWithIndexFromSelf:sender.titleLabel.text.integerValue];
    // 传入参数为几,就向前pop几层。
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant