Skip to content

Instantly share code, notes, and snippets.

@aiwilliams
Created May 16, 2012 13:52
Show Gist options
  • Save aiwilliams/2710489 to your computer and use it in GitHub Desktop.
Save aiwilliams/2710489 to your computer and use it in GitHub Desktop.
Storyboard in RubyMotion 1.4

Start XCode and create a new Storyboard file. I closed all my other XCode projects. When you choose the location of the created file, it should be your RubyMotion project's resources directory. Add a UIViewController, and set it's identifier property to "Start". Add some UI elements so you can see it working.

When you run rake in your RubyMotion project, it will compile the .storyboard file. You could auto-load the Storyboard using a plist configuration, but you'll see code can do it too.

class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
storyboard = UIStoryboard.storyboardWithName("Storyboard", bundle: NSBundle.mainBundle)
view_controller = storyboard.instantiateViewControllerWithIdentifier("Start")
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame)
@window.rootViewController = view_controller
@window.makeKeyAndVisible
true
end
end
@jonathak
Copy link

Thanks for sharing this. Very nice. It works great for me on simulator, but not device. I'm not sure why. Have you tried running it on a devie?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment