开发者

Downsides of using UINavigationController only for the UINavigationBar?

开发者 https://www.devze.com 2023-04-04 16:36 出处:网络
I have a UITabBarController with four view 开发者_如何学Gocontrollers. Two of those need to be UINavigationControllers the other two don’t. However, I want to show the same UINavigationBar layout on

I have a UITabBarController with four view 开发者_如何学Gocontrollers. Two of those need to be UINavigationControllers the other two don’t. However, I want to show the same UINavigationBar layout on each of these controllers. I could of course add a UINavigationBar to the two normal view controllers, however, I would prefer to have one UIViewController base class which creates the bar items and subclass all four view controllers from this base class.

The simplest way to make this work is to wrap all four view controllers in a UINavigationController, even though in two case the navigational aspect won't actually be used. Are there any downsides to this approach and/or are there better simple alternatives?


The only downside I could see are possibly a (VERY marginally) slower load time of the view and the lack of space for uibuttons (if you need more than just 2 buttons, then you're very nearly out of luck) . Uinavigationcontroller instantiation is usually done in the viewDidLoad method or in the application delegate. What I would recommend is simply making the uitoolbar's height rect 44.0 (or I've heard 45 being tossed around) and setting it's background color to that of a navigationbar.

Overall, unless every nanosecond counts in app loading (LOL) I would see no huge issues when using only uinavigationbars.

Cheers (apologies for how long your question went unanswered).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号