Closed matthewsinclair closed 9 years ago
D'Oh. RTFM. See on_init
vs on_load
. My bad.
You know, we ran into this same issue just last week. And we wrote the Fn manual. haha
Haha. Anyway, this is how I got around it:
class HomeScreen < PM::Screen
title "Home"
def on_init
@featured_screen = FeaturedScreen.new(nav_bar: true)
@shop_screen = ShopScreen.new(nav_bar: true)
@bag_screen = BagScreen.new(nav_bar: true)
@stores_screen = StoresScreen.new(nav_bar: true)
@account_screen = AccountScreen.new(nav_bar: true)
end
def on_load
open_tab_bar @featured_screen, @shop_screen, @bag_screen, @stores_screen, @account_screen
[ 'Account', 'Stores', 'Bag', 'Shop', 'Featured' ].each {|s| open_tab s }
end
end
Oh, btw: any ideas on the best way to use SVGs as tab bar item icons? I've had a quick look at SVGKit, which makes it easy to load the SVGs, but none of the PM tab bar item stuff seems to want to display them.
I've never tried! If you figure out a way, would you want to contribute? That would be awesome.
Also, wouldn't just putting each individual screen's set_tab_bar_item
in on_init
work better than cycling through all of them? You could also use the class method, if you want.
class FeaturedScreen < PM::Screen
title "Featured"
tab_bar_item title: "Featured", item: "icons/featured"
end
Good point. And re: SVG, yep, I’ll try to. I found a lib that handles them, but I couldn’t get them to display in a tab bar. Still working on it ...=
Awesome.
I have a very simple app with a tab that has 5 tab bar items in it. I have two questions:
Here's the controller code that establishes the tabs:
Each screen is just an empty
PM::Screen
with a tab item specification like this:I even tried to manually select the tabs (see
on_appear
) but that makes no difference.When the app runs, it looks like this when it first displays:
And then if I tap on each tab bar item, it looks like this:
I'm not doing anything special or out of the ordinary. This is just plain, vanilla PM tab bar item code. Any help would be much appreciated.