rubyrubymotionrubymotion-promotion

add child screen to parent screen with rmq


In the on_load method of HomeScreen class i want to do something like rmq.append(LoginScreen, :login_form). LoginScreen inherits from PM::FormScreen. enter image description here

Since I am not implementing initWithFrame in LoginScreen the app crashes.

This has been done in http://jamonholmgren.com/getting-started-with-motionkit-and-promotion/ but with motion kit. How can I achieve the same with rmq?


Solution

  • You're going to need to create an instance of the screen and then add its view.

    def on_load
      @login_screen = LoginScreen.new
      addChildViewController @login_screen
      rmq.append(UIImageView, :logo)
      rmq.append(@login_screen.view, :login_form)
    end
    

    The addChildViewController ensures that lifecycle events are properly called on LoginScreen.