Last active
December 15, 2015 11:59
-
-
Save paulsturgess/5256999 to your computer and use it in GitHub Desktop.
Idea for a standard approach to setting up the basics of a RubyMotion app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AppController < UIViewController | |
| def loadView | |
| self.view = AppView.alloc.init | |
| end | |
| def viewDidLoad | |
| super | |
| view.viewDidLoad | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AppDelegate | |
| def application(application, didFinishLaunchingWithOptions:launchOptions) | |
| @window = AppWindow.alloc.initWithFrame | |
| true | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AppView < UIView | |
| def viewDidLoad | |
| self.addSubview(label) | |
| # ... | |
| end | |
| def label | |
| @label ||= CustomLabel.alloc.initWithFrame | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AppWindow < UIWindow | |
| def initWithFrame | |
| super(UIScreen.mainScreen.bounds) | |
| self.send(:initialize) | |
| self | |
| end | |
| def initialize | |
| self.makeKeyAndVisible | |
| self.rootViewController = appController | |
| end | |
| def appController | |
| @appController ||= AppController.alloc.init | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CustomLabel < UILabel | |
| def initWithFrame | |
| super([[10,60], [300,80]]) | |
| self.send(:initialize) | |
| self | |
| end | |
| def initialize | |
| self.backgroundColor = UIColor.lightGrayColor | |
| self.text = "Some text..." | |
| # ... | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment