Skip to content

Instantly share code, notes, and snippets.

@sxross
Created April 21, 2013 16:49
Show Gist options
  • Save sxross/5430230 to your computer and use it in GitHub Desktop.
Save sxross/5430230 to your computer and use it in GitHub Desktop.
Example of using NUI with RubyMotion
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
NUISettings.init
NUIAppearance.init
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
tabbar = UITabBarController.alloc.init
table_view_controller = ExampleTableViewController.alloc.init
@window.rootViewController = UINavigationController.alloc.initWithRootViewController(table_view_controller)
@window.makeKeyAndVisible
true
end
end
class ExampleTableViewController < UITableViewController
@@cell_identifier = nil
# Sample data for our table. Don't blame me for the data.
# I just grabbed it off the Web :)
CELL_DATA = [
['John', 'Guitar'],
['Paul', 'Bass'],
['George', 'Guitar'],
['Ringo', 'Drums']
]
## Table view data source
def numberOfSectionsInTableView(tableView)
1
end
def tableView(tableView, numberOfRowsInSection:section)
CELL_DATA.length
end
def tableView(tableView, cellForRowAtIndexPath:indexPath)
cell = tableView.dequeueReusableCellWithIdentifier(cell_identifier)
unless cell
cell = UITableViewCell.alloc.initWithStyle UITableViewCellStyleSubtitle, reuseIdentifier:cell_identifier
end
cell.textLabel.text = CELL_DATA[indexPath.row].first
cell.detailTextLabel.text = CELL_DATA[indexPath.row].last
cell
end
def cell_identifier
@@cell_identifier ||= 'example_cell'
end
end
source "https://rubygems.org"
gem "rake"
gem "motion-cocoapods", "1.3.0.rc1"
gem 'bubble-wrap'
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'bundler'
Bundler.require
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'nui'
app.pods do
pod 'NUI'
end
app.frameworks += ['CoreImage', 'QuartzCore']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment