Thursday, 15 May 2014

ios - How Can I Trigger a Segue From Pan Gesture? -



ios - How Can I Trigger a Segue From Pan Gesture? -

i have next pan gesture code set on uiviewcontroller in storyboard.

in viewdidload:

uipangesturerecognizer *panrecognizer = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(pandetected:)]; [self.view addgesturerecognizer:panrecognizer];

then have next called:

#pragma mark - gesture recognizers - (void)pandetected:(uipangesturerecognizer *)panrecognizer { cgpoint velocity = [panrecognizer velocityinview:self.view]; nslog(@"pan detected."); if(velocity.x > 0) { nslog(@"pan went right."); } else { nslog(@"pan went left."); if (panrecognizer.state == uigesturerecognizerstatechanged) nslog(@"state changed."); } }

the above code fires when drag finger left right. want trigger if drag right border of screen. want segue uiviewcontroller on storyboard. (i want drag on settings screen modally onto main screen in app right edge). settings uiviewcontroller needs drag onto screen partially.

-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender{ nslog(@"prepareforsegue: %@", segue.identifier); if([segue.identifier isequaltostring:@"settings"]) { nslog(@"show settings view controller"); olstoryboardlink *storyboardlink = segue.destinationviewcontroller; //send string storyboardlink.setstoryboardname = @"settings"; storyboardlink.transitioningdelegate = self; [self presentviewcontroller:storyboardlink animated:yes completion:nil]; } }

how can trigger segue pan gesture right border of screen?

segues can't performed viewcontroller in storyboard a viewcontroller in storyboard b. utilize segues, 2 viewcontroller have in same storyboard.

but reply question, trigger segue calling performseguewithidentifier: method:

- (void)pandetected:(uipangesturerecognizer *)panrecognizer { cgpoint velocity = [panrecognizer velocityinview:self.view]; nslog(@"pan detected."); if (velocity.x > 0) { nslog(@"pan went right."); } else { nslog(@"pan went left."); if (panrecognizer.state == uigesturerecognizerstatechanged) nslog(@"state changed."); [self performseguewithidentifier:@"settings" sender:panrecognizer]; } }

for more informations, see apple's reference

ios uiviewcontroller uistoryboardsegue uipangesturerecognizer

No comments:

Post a Comment