Hiding a UINavigationController's UIToolbar during viewWillDisappear:

后端 未结 11 1821

I\'ve got an iPhone application with a UITableView menu. When a row in the table is selected, the appropriate view controller is pushed onto the application\'s

11条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-03 21:32

    To show toolbar in new view controller just add this:

    - (void)viewWillAppear:(BOOL)animated
    {
        [self.navigationController setToolbarHidden:NO animated:animated];
        [super viewWillAppear:animated];
    }
    

    To hide toolbar:

    - (void)viewWillAppear:(BOOL)animated
    {
        [self.navigationController setToolbarHidden:YES animated:animated];
        [super viewWillAppear:animated];
    }
    

    When traveling between screens push new view controller with following code:

    SettingsRecordingViewController *vc = [[SettingsRecordingViewController alloc] initWithNibName:@"SettingsRecordingViewController" bundle:[NSBundle mainBundle]]; 
    [self.navigationController pushViewController:vc animated:YES];      
    [vc release];
    

    and if it has different state of toolbar (hidden/shown) then nice animation of hiding/showing toolbar will be shown.

提交回复
热议问题