iOS: popViewController unexpected behavior

后端 未结 7 1925
迷失自我
迷失自我 2020-12-02 16:52

I\'ve been searching the internet for a solution. There\'s nothing I could find. So: I\'m using a UINavigationController. I am pushing two UIViewControllers onto it. In the

7条回答
  •  Happy的楠姐
    2020-12-02 17:21

    yeah, unfortunately apple did not synchronize UINavigationController's animations. Andrew's solution is excellent, but if you don't want to cover its whole functionality, there is a simpler solution, override these two methods :

    // navigation end event
    
    - ( void )  navigationController    : ( UINavigationController* ) pNavigationController 
                didShowViewController   : ( UIViewController*       ) pController 
                animated                : ( BOOL                    ) pAnimated
    {
    
        if ( [ waitingList count ] > 0 ) [ waitingList removeObjectAtIndex : 0 ];
        if ( [ waitingList count ] > 0 ) [ super pushViewController : [ waitingList objectAtIndex : 0 ] animated : YES ];
    
    }
    
    
    - ( void )  pushViewController  : ( UIViewController* ) pController 
                animated            : ( BOOL ) pAnimated
    {
    
        [ waitingList addObject : pController ];
        if ( [ waitingList count ] == 1 ) [ super pushViewController : [ waitingList objectAtIndex : 0 ] animated : YES ];
    
    }
    

    and create an NSMutableArray instance variable called waitingList, and you are done.

提交回复
热议问题