winnie2012
2014-12-19 11:00:26 +08:00
RubyMotion 3.0 支持使用 Ruby 开发 iOS / Android / Mac , 你能看懂如下代码对吗?
`
# app/app_delegate.rb
class AppDelegate < PM::Delegate
status_bar true, animation: :fade
def on_load(app, options)
open RootScreen.new(nav_bar: true)
end
end
# app/screens/root_screen.rb
class RootScreen < PM::Screen
title "Root Screen"
def on_load
set_nav_bar_button :right, title: "Help", action: :open_help_screen
end
def open_help_screen
open HelpScreen
end
end
# app/screens/help_screen.rb
class HelpScreen < PM::TableScreen
title "Table Screen"
def table_data
[{
title: "Help",
cells: [
{ title: "About this app", action: :tapped_about },
{ title: "Log out", action: :log_out }
]
}]
end
def tapped_about(args={})
open AboutScreen
end
def log_out
# Log out!
end
end
`