i have pkrevealcontroller front , right views. pan gesture enabled, can open right view swipe - great. swiping way doesn't anything, shouldn't, because there's no left controller open - great. instead, want implement swipe (left right) trigger app's back-navigation.
i've added swipe gesture recognizer (front) view controller - nothing happens.
if setrecognizespanningonfrontview:no on reveal controller, newly added gesture recognizer works - can navigate back.
so, it's either 1 or other. want both. how can that?
i've implemented own solution. 2 solutions actually, needed different ones cases when allowed , disallowed pkrevealcontroller swipe actions.
case 1: setrecognizespanningonfrontview:no
this case quite easy - add uiswipegesturerecognizer calls back method:
uiswipegesturerecognizer *backswipe = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(back)]; [backswipe setdirection:uiswipegesturerecognizerdirectionright]; [self.view addgesturerecognizer:backswipe]; case 2: setrecognizespanningonfrontview:yes
this 1 more complicated. in order avoid gesture recogniser conflict, had tap pkrevealcontroller's gesture recogniser. of course, implemented when pkrevealcontroller not have leftviewcontroller.
so, register class want implement swipe navigation listener notifications:
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(back:) name:notification_back_swipe object:self]; and in pkrevealcontroller.m file, in - (void)movefrontviewrightwardsifpossible method, post notification:
[[nsnotificationcenter defaultcenter] postnotificationname:notification_back_swipe object:[(uinavigationcontroller *)self.frontviewcontroller topviewcontroller]]; here passing notification's object recipient uiviewcontroller itself. i'm doing specific uiviewcontroller instance reacts notification. otherwise if had more uiviewcontrollers in uinavigationcontroller stack subscribed receive notification, cause uinavigationcontroller popviewcontroller, result in random number of steps while want happen once.
that's it. enjoy.
Comments
Post a Comment