NimbleKit - fast iOS app development

Tab controller doesn't allow parameters for pages

Problem discussions

Tab controller doesn't allow parameters for pages

Postby Nephilim » Thu Jun 25, 2009 5:04 pm

It seems like the tab controller cannot handle file names with parameters. For instance, suppose you had 'category' pages which pull data from a SQLite database based on an identifier passed in. This will not work:

Code: Select all
   var tabController = new NKTabBarController(); 
    tabController.setTabBarForPage("main.html", "Home", "home.png");
    tabController.setTabBarForPage("category.html?id=1", "People", "people.png");
    tabController.setTabBarForPage("category.html?id=2", "Places", "places.png");
    tabController.setTabBarForPage("category.html?id=3", "Things", "things.png");


In the above code, the tab bar would only have two buttons: Home and People, and stop adding buttons afterwords. I suppose because NK views 'category.html' as the same page.

The workaround is to create three pages (people.html, places.html, things.html) and hard-code the identifiers into them. By abstracting your html display for categories into a javascript library, these pages can be very small:

Code: Select all
<!-- people.html -->
<script type="text/javascript" src="category.js"></script>
<script type="text/javascript">
   category.display( 1 );  // 1 is the identifier for 'people'.
</script>


...but it would be nice if the tab controller allows you to pass in parameters.


(Edit...) Or, just use a toolbar instead of a tab controller...
Nephilim
 
Posts: 17
Joined: Tue Jun 23, 2009 5:58 pm

Re: Tab controller doesn't allow parameters for pages

Postby sunny » Thu Jun 25, 2009 6:21 pm

TabController architecture does not allow to navigate with parameters :(
User avatar
sunny
Staff
 
Posts: 2666
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: Tab controller doesn't allow parameters for pages

Postby Nephilim » Fri Jun 26, 2009 12:07 am

sunny wrote:TabController architecture does not allow to navigate with parameters :(


Not a problem. The number of "special case" HTML pages linked to off of the tab controller is small and finite, so the hard-coded landing page approach should not be a show-stopper for anyone.
Nephilim
 
Posts: 17
Joined: Tue Jun 23, 2009 5:58 pm

Re: Tab controller doesn't allow parameters for pages

Postby band-x » Fri Jun 26, 2009 12:35 am

I can think of a few cases where adding variables to a page request made via TabController would be essential.

Not by using page id's as in your example but in passing variables from page to page... very basic example:

'radio.html?showid=151' page has a TabController with a button that links to 'tracklist.html?showid=151'
band-x
 
Posts: 34
Joined: Tue Jun 02, 2009 11:24 am

Re: Tab controller doesn't allow parameters for pages

Postby Nephilim » Fri Jun 26, 2009 6:33 am

band-x wrote:I can think of a few cases where adding variables to a page request made via TabController would be essential.

Not by using page id's as in your example but in passing variables from page to page... very basic example:

'radio.html?showid=151' page has a TabController with a button that links to 'tracklist.html?showid=151'


Correct me if I'm wrong, but it seems that TabControllers are meant to be static across the application, giving access to major areas of the app. I say this because they don't scroll away when you go from page to page in the app; they stay fixed at the bottom of the screen. Used in this way, you'd only have a small number of destinations for those buttons.

If you wanted something that comes and goes, and thus might show up with many different contexts and with different targets for the buttons, you would instead use a toolbar. These elements slide away with pages. There could potentially be very many of these, but with toolbars, because they call functions instead of going to predefined pages, you can use them with parameters, which should address the issue you mention. (Or does it not?)
Nephilim
 
Posts: 17
Joined: Tue Jun 23, 2009 5:58 pm


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 1 guest