Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

how could i pop to root controller? #16

Open
cs13886 opened this issue Jan 26, 2014 · 2 comments
Open

how could i pop to root controller? #16

cs13886 opened this issue Jan 26, 2014 · 2 comments

Comments

@cs13886
Copy link

cs13886 commented Jan 26, 2014

No description provided.

@cs13886
Copy link
Author

cs13886 commented Apr 2, 2014

I write a categary for FlipBoardNavigationController .
So it has two new function

  1. -(void)popToViewController:(UIViewController*)toViewController;
    you can use this pop to any controller in FlipBoardNavigationController.viewcontrollers

2-(void)popToRootViewController;
you can easy pop to the root viewcontroller

***************FlipBoardNavigationController.h ***
// FlipBoardNavigationController+extention.h
//
// Created by CHEN on 14-3-19.
//

#import "FlipBoardNavigationController.h"

@interface FlipBoardNavigationController (extention)

-(void)popToViewController:(UIViewController*)toViewController;
-(void)popToRootViewController;

@EnD

***************FlipBoardNavigationController.h end ***

***************FlipBoardNavigationController.m ***
//
// FlipBoardNavigationController+extention.m
//
// Created by CHEN on 14-3-19.
//

#import "FlipBoardNavigationController+extention.h"
#import <FlipBoardNavigationController.h>

@implementation FlipBoardNavigationController (extention)

-(void)popToViewController:(UIViewController*)toViewController{

NSMutableArray *controllers = self.viewControllers;
NSInteger index = [controllers indexOfObject:toViewController];
UIViewController *needRemoveViewController;

for (int i = controllers.count - 2; i >index; i--) {

    needRemoveViewController = [controllers objectAtIndex:i];
    [needRemoveViewController.view setAlpha:0];

    [needRemoveViewController removeFromParentViewController];
    [controllers removeObject:needRemoveViewController];
}

[self popViewController];

}

-(void)popToRootViewController{
UIViewController *rootController = [self.viewControllers objectAtIndex:0];
[self popToViewController:rootController];
}

************_FlipBoardNavigationController.m end_

@leopardvipman
Copy link

非常感谢啊

------------------ 原始邮件 ------------------
发件人: "Jun.Chen";notifications@github.com;
发送时间: 2014年4月2日(星期三) 上午10:21
收件人: "michaelhenry/FlipBoardNavigationController"FlipBoardNavigationController@noreply.github.com;

主题: Re: [FlipBoardNavigationController] how could i pop to rootcontroller? (#16)

I write a categary for FlipBoardNavigationController .
So it has two new function

  1. -(void)popToViewController:(UIViewController*)toViewController;
    2-(void)popToRootViewController;

***************FlipBoardNavigationController.h ***
// FlipBoardNavigationController+extention.h
//
// Created by CHEN on 14-3-19.
//

#import "FlipBoardNavigationController.h"

@interface FlipBoardNavigationController (extention)

-(void)popToViewController:(UIViewController*)toViewController;
-(void)popToRootViewController;

@EnD

***************FlipBoardNavigationController.h end ***

***************FlipBoardNavigationController.m ***
//
// FlipBoardNavigationController+extention.m
//
// Created by CHEN on 14-3-19.
//

#import "FlipBoardNavigationController+extention.h"
#import

@implementation FlipBoardNavigationController (extention)

-(void)popToViewController:(UIViewController*)toViewController{
NSMutableArray *controllers = self.viewControllers; NSInteger index = [controllers indexOfObject:toViewController]; UIViewController *needRemoveViewController; for (int i = controllers.count - 2; i >index; i--) { needRemoveViewController = [controllers objectAtIndex:i]; [needRemoveViewController.view setAlpha:0]; [needRemoveViewController removeFromParentViewController]; [controllers removeObject:needRemoveViewController]; } [self popViewController];
}

-(void)popToRootViewController{
UIViewController *rootController = [self.viewControllers objectAtIndex:0];
[self popToViewController:rootController];
}

************_FlipBoardNavigationController.m end_


Reply to this email directly or view it on GitHub.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants