NavigationController does not pop up the "Backward Back View" button

Having a simple navigation controller (start of a project based on navigation) I created a new View with an XIB file.

on mine HomeViewController(The initial screen with all the parameters UIButtonI have:

@implementation HomeViewController

-(IBAction) optionChoosed:(UIButton *)button
{
    NSString *msg = [NSString stringWithFormat:@"Button: %d", button.tag];
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Hi" message:msg delegate:nil cancelButtonTitle:@"Go away" otherButtonTitles:nil];

    switch (button.tag) {
        case 13:
            // Simple Search
            [self loadSimpleSearch]; break;

        default:
            [alert show];           
            break;
    }
    [alert release];
}

-(void)loadSimpleSearch
{
    SimpleSearchViewController *controller = 
        [[SimpleSearchViewController alloc] initWithNibName:@"SimpleSearchViewController" bundle:nil];

    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}

Witch works great!

it pushes View onto the front of the stack!

Now, as in my first presentation SimpleSearchViewControllerI have self.title = @"myTitle";, I get a header in NavigationBar, as well as the back button (because I have the same setup on HomeViewController)

I thought that NavigationViewController would handle the popup of the current view, but that is not the case.

What do I need to do to place SimpleSearchViewController?

Where can i use [self.navigationController popViewControllerAnimated:YES];

, ViewDidUnload .

, ​​ ViewController, HomeViewController, , , , : -/

, .

HomeViewController

alt text http://cl.ly/XNS/Screen_shot_2010-04-21_at_22.38.51.png

SimpleSearchViewController

alt text http://cl.ly/YDw/Screen_shot_2010-04-21_at_22.40.00.png

SimpleSearchViewController ""

alt text http://cl.ly/XLO/Screen_shot_2010-04-21_at_22.40.21.png


, , HomeViewController NavigationViewController

alt text

+3
1

, , navigationItem , , popping

-(UINavigationItem*) navigationItem
{
    UINavigationItem* item = [super navigationItem];
    item.title = @"search";
    return item;
}
+1

Source: https://habr.com/ru/post/1742168/


All Articles