UINavigationController當設置根控制器的時候,意思就是把根控制器壓入棧內,當咱們push的時候,咱們把下一個控制器壓入棧內,當咱們pop的時候把上面的控制器的內存釋放
UITabBarController的使用步驟
初始化UITabBarController
設置UIWindow的rootViewController爲UITabBarController
根據具體狀況,經過addChildViewController方法添加對應個數的子控制器
UITabBarController添加控制的方式有2種
添加單個子控制器
- (void)addChildViewController:(UIViewController *)childController
設置子控制器數組
@property(nonatomic,copy) NSArray<__kindof UIViewController *> *viewControllers;
UITabBar
若是UITabBarController有N個子控件,那麼UITabBar內部就會有N個UITabBarButton作爲子控件
若是UITabBarController有4個子控制器,那麼UITabBar的結構大體以下圖所示
UITabBarButton
UITabBarController的view結構