ios - Right To Left Push animation results in corrupted navigation bar -
i'm subclassing uinavigationcontroller
perform push right left (not normal behavior) uirtlnavigationcontroller.m i've added @ bottom of question , these warnings:
nested push animation can result in corrupted navigation bar finishing navigation transition in unexpected state. navigation bar subview tree might corrupted.
i've researched these errors , found class prevents receiving them: https://github.com/plasma/bufferednavigationcontroller
i've added bufferednavigationcontroller .h , .m project, changed line in bufferednavigationcontroller.h to: @interface bufferednavigationcontroller : uirtlnavigationcontroller , seted bufferednavigationcontroller uinavigationcontroller
custom subclass in ib.
views still moving right left , methods getting called inside bufferednavigationcontroller i'm still warnings nested , ..navigation bar subview tree might corrupted..
any appreciated.
uirtlnavigationcontroller.m:
#import "uirtlnavigationcontroller.h" @implementation uirtlnavigationcontroller - (id)initwithrootviewcontroller:(uiviewcontroller *)rootviewcontroller { self = [super initwithrootviewcontroller:rootviewcontroller]; if (!self) return nil; return self; } - (void)pushviewcontroller:(uiviewcontroller *)viewcontroller animated:(bool)animated { nslog(@"pushviewcontroller"); // add viewcontroller , fake controller without animation. pop fake controller animation. uiviewcontroller *fakecontroller = [[[uiviewcontroller alloc] init] autorelease]; [super setviewcontrollers:[[self viewcontrollers] arraybyaddingobjectsfromarray:[nsarray arraywithobjects:viewcontroller, fakecontroller, nil]] animated:no]; [super popviewcontrolleranimated:animated]; } - (void)popviewcontrolleranimatedstep2:(uiviewcontroller *)viewcontroller { // push new top controller animation [super pushviewcontroller:viewcontroller animated:yes]; // remove view should have been popped nsmutablearray *arr = [nsmutablearray arraywitharray:[self viewcontrollers]]; [arr removeobjectatindex:[[self viewcontrollers] count]-2]; [super setviewcontrollers:[nsarray arraywitharray:arr] animated:no]; } - (uiviewcontroller *)popviewcontrolleranimated:(bool)animated { nslog(@"popviewcontrolleranimated"); if (animated) { // save controller should on top after pop operation uiviewcontroller *newtopcontroller = [[self viewcontrollers] objectatindex:[[self viewcontrollers] count]-2]; // remove stack. leave view should popped on top nsmutablearray *arr = [nsmutablearray arraywitharray:[self viewcontrollers]]; [arr removeobjectatindex:[[self viewcontrollers] count]-2]; [super setviewcontrollers:[nsarray arraywitharray:arr] animated:no]; // schedule next step [self performselector:@selector(popviewcontrolleranimatedstep2:) withobject:newtopcontroller afterdelay:0]; return [arr objectatindex:[arr count]-1]; } return [super popviewcontrolleranimated:no]; } - (void)dealloc { [super dealloc]; } @end
i don't know if creating custom uinavigationcontroller perform custom transition, if do, there easier way it. following code
-(void)makemycustomanimation { yourdestinationviewcontroller *destinationcontroller = [yourdestinationviewcontroller alloc] initwithnib.....];//add missing code fot ini catransition* transition = [catransition animation]; transition.duration = .25; //you can change value fit needs transition.timingfunction = [camediatimingfunction functionwithname: kcamediatimingfunctioneaseineaseout]; //kcamediatimingfunctionlinear //kcamediatimingfunctioneasein //kcamediatimingfunctioneaseout //kcamediatimingfunctioneaseineaseout //kcamediatimingfunctiondefault transition.type = kcatransitionpush; //kcatransitionmovein; //kcatransitionpush, //kcatransitionreveal //kcatransitionfade transition.subtype = kcatransitionfromright; //kcatransitionfromleft, //kcatransitionfromright //kcatransitionfromtop, //kcatransitionfrombottom [self.navigationcontroller.view.layer addanimation:transition forkey:kcatransition]; [self.navigationcontroller pushviewcontroller:destinationcontroller animated:no];
}
you can change direction of transition changing subtype
value.(i might set wrong value of subtype, keep mixing them)
also can use same approach pop
-ing view controller. i
and can used if want use segues, create custom segue , overrode -(void)perform
method adding previous code additions, have view controllers [self sourceviewcontroller];
, [self destinationviewcontroller];
Comments
Post a Comment