-1

I need some guidance to add UINavigation controller and also add Button in Navigation using ruby Motion.

Ayush
  • 3,989
  • 1
  • 26
  • 34

2 Answers2

2

This is a pretty broad question, so I am assuming you're pretty new to iOS development in general. You'll want to reference the UINavigationController API documentation, found here:

http://www.rubymotion.com/developer-center/api/UINavigationController.html

If you're looking for an easier way to do this, have a look at ProMotion:

https://github.com/clearsightstudio/ProMotion/

This abstracts your UINavigationController and allows you to focus on your app programming rather than managing navigation.

Jamon Holmgren
  • 23,738
  • 6
  • 59
  • 75
1

Pretty basic stuff, you should look at some samples available from the rubymotion site. In your app_delegate, at startup, you setup the navigation controller, and hand it an instance of your main view controller (the first view you intend to show, there's nothing magical about the name mainViewController). That starts the view controller stack that is managed by the navigation controller.

def application(application, didFinishLaunchingWithOptions:LaunchOptions)
    @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
    @mainViewController = MainViewController.alloc.initWithNibName(nil, bundle:nil)
    @window.rootViewController = UINavigationController.alloc.initWithRootViewController(@mainViewController)
    @window.makeKeyAndvisible
    true
end

To add a button to the nav bar, you need to create a UIBarButtonItem, and add it to the current navigationItem.

As Jamon mentioned, check out the api docs.

railsdog
  • 1,503
  • 10
  • 10