Create a modal view using the navigation bar and back button

I want to create a modal view with a navigation element (the right view in my screenshot), and I want it to have a back button. My application is the TabBar application, and I do not want the tab bar in this view, but I want to load the previous view (the left image in my screenshot) with a step similar to the "push" type. I can only create a push segue to ensure correct navigation back to the left view, if it is loaded as a modal view, the NavigationBar and TabBar are gone. Any workarounds for this? Thanks in advance!

Here's my screenshot

+5
source share
2 answers

Navbar . , .h . , , , [self dismissModalViewControllerAnimated:YES];

, , :

@protocol SecondViewControllerDelegate <NSObject>

-(void) done;

@end

@interface SecondViewController : UIViewController {
    ...
    id delegate;
}

...

@property (nonatomic, assign) id<SecondViewControllerDelegate> delegate;

-(IBAction)done:(id)sender;  //this will be linked to your nav bar button.
@end

:

-(IBAction)done:(id)sender{
   [self.delegate done];
}

<SecondViewControllerDelegate>

, .

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([[segue identifier] isEqualToString:@"Second View Modal Segue Identifier"])
    {
        SecondViewController *viewController = segue.destinationViewController;
        viewController.delegate = self;
    }
}

, :

-(void) done
{
    [self dismissModalViewControllerAnimated:YES];
}

. , , .

+12

. IB Editor -> Embed In -> Navigation Controller, IB , .

+6

All Articles