Hiding a UINavigationController's UIToolbar during viewWillDisappear:

后端 未结 11 1723

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:30

    Managing the toolbar state (i.e. which VC needs/doesn't need the toolbar) gets tricky quickly.

    I've had success with following this rule:

    For each view controller, in viewWillAppear(), decide if it needs a toolbar or doesn't, then call navigationController?.setToolbarHidden(true or false, animated: animated) respectively.

    This way, each view controller starts out with the correct toolbar state and you don't have to worry about "restoring" the toolbar state when the view controller is dismissed.

提交回复
热议问题