Understanding View Controller Nesting in iOS

前端 未结 3 979
天命终不由人
天命终不由人 2021-02-04 04:08

Ive been tearing my hair out over the last couple of days trying to understand this one seemingly basic concept of iOS development:

  • If I want to have two or mor

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 05:07

    This is definitively possible in IOS 4 :

    You have a view controller "A" with its view :

    • Alloc init the view controller "B" you want to had on your view controller "A"
    • Call (void)addSubview:(UIView *)view on the view of the view controller "A" with the view of the view controller "B" as parameter
    • The frame of the view of the view controller "B" is set to fullscreen because of addSubView, so change it to put the view where you want on the view of view controller "A".
    • Add some UIView animations when you change the frame to have a good display.

    On IOS5 just use the method on your view controller "A" :

    • (void)addChildViewController:(UIViewController *)childController

提交回复
热议问题