简体   繁体   中英

Get Tap Gesture to link back to the First View without back button?

Currently I have a Master View and a Detail View. In the detail there is an image I added a TapGestureRecognizer to. And then on the TapGestureRecognizer I added a segue push back to the master view. The problem is in the simulator when I click on the image it takes me to the Master View but the back button in the navigator item says the name of the detail view.

I want the tap gesture to link back to the first master view. Instead of linking to a master view with a back button. How could I do this though? I think it has to do with prepare Segue.

Any Help?

Thanks in advance!

Just pop the view controller. Call the method:

[self.navigationController popViewControllerAnimated:YES];

and it will go back to the previous view.

Took a couple hours but I saw I didnt need a segue but just had to handle the tap gesture in my class:

     UITapGestureRecognizer *singleFingerTap =
        [[UITapGestureRecognizer alloc] initWithTarget:self
                                                action:@selector(handleSingleTap:)];
        [self.view addGestureRecognizer:singleFingerTap];

    }

    - (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
        //The event handling method
        [self.navigationController popToRootViewControllerAnimated:YES];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM