Skip to content
artgreen edited this page Sep 13, 2010 · 2 revisions

This is a very basic example.

Create a controller for testing:


./script/generate controller welcome

Controller code (welcome_controller.rb):

class WelcomeController < ApplicationController acts_as_iphone_controller :test_mode => true class ListItem def initialize( num ) @num = num end def caption “Item #{@num.to_s}” end def url “/welcome/#{@num.to_s}” end end def index @list = Array.new for i in 1..5 do @list.push( ListItem.new( i ) ) end respond_to do |format| format.html # use index.erb format.iphone # use index.iphone.erb end end

end


View code (index.iphone.erb):


<%= l = { :caption => 'Home', :url => "/welcome", :html_options => {} } r = { :back => true, :caption => 'Back', :url => "/", :html_options => {} } te_navigation_bar( r, "Test.app", l ) %> <%= te_list @list %>

This should produce a single screen with a toolbar at the top and a list beneath it.

Clone this wiki locally