Hiding a UINavigationController's UIToolbar during viewWillDisappear:

后端 未结 11 1818

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

    The issue here is that the UITableView's frame is set so that it does not overlap with the UIToolbar. That is, it sits just above the UIToolbar. When you push the next UIViewController to the UINavigationController stack, while removing the UIToolbar, there is nothing to show but the UIWindow behind it, unless you put something there in its place.

    One workaround without the awkward animation after transition is to place your UITableView in a UIView "container" that shares the same frame as your regular view, but underlaps the UIToolbar with the desired colour that you wish to see during the transition (e.g. white).

    To enact the underlap, you could set your UIViewController to wantsFullScreenLayout = YES. You would then ensure that your UITableView has the same frame as it would have before the use of the container. i.e. it sits below the navigation bar, and above the toolbar.

    This can be made more elegant by writing a custom UIViewController and use that instead of the UITableViewController, or by being sneaky and inserting the new UIView "container" beneath the UITableView in your existing UITableViewController.

提交回复
热议问题