Skip to content

Instantly share code, notes, and snippets.

@Omnipresent
Last active December 15, 2015 22:49
Show Gist options
  • Save Omnipresent/5335890 to your computer and use it in GitHub Desktop.
Save Omnipresent/5335890 to your computer and use it in GitHub Desktop.
class AnotherController < UIViewController
def loadView
end
def viewDidLoad
super
@label = UILabel.new
@label.text = 'Some Foo text'
@label.frame = [[50,50],[150,50]]
self.view.addSubview(@label) #app runs fine if this is deleted
end
end
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.makeKeyAndVisible
nav = UINavigationController.alloc.initWithRootViewController(HomeController.alloc.initWithNibName(nil, bundle:nil))
nav.wantsFullScreenLayout = true
@window.rootViewController = nav
true
end
end
class HomeController < UIViewController
def viewWillAppear(animated)
super
self.navigationController.navigationBarHidden = true
end
def viewWillDisappear(animated)
super
self.navigationController.navigationBarHidden = false
end
def viewDidLoad
super
button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
button.frame = [[15,100], [280,50]]
button.setTitle("Move to next view", forState: UIControlStateNormal)
button.addTarget(self,
action: "moveToChildView:",
forControlEvents: UIControlEventTouchUpInside)
self.view.addSubview button
end
def moveToChildView (sender)
self.parentViewController.pushViewController(AnotherController.alloc.initWithNibName(nil, bundle: nil), animated:true)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment