NKTabBarController
Overview
TabBarController class is used to manipulate pages giving user more freedom in navigation.
NKTabBarController()
Creates and initializes NKTabBarController object also makes empty tab controller to appear on screen.
destroy()
Completely removes controller from page.
setTabBarForPage(page, title, image)
Every tab should be created using this method, normally current page, for instance index.html, should be setup first.
Parameters: page - name of page to be displayed when tab selected title - title to be displayed on tab icon image - image to be displayed over tab title, if you want to use standard iPhone images, you can specify image number from the list instead of filename:
UITabBarSystemItemFavorites = 1
UITabBarSystemItemFeatured = 2
UITabBarSystemItemTopRated = 3
UITabBarSystemItemRecents = 4
UITabBarSystemItemContacts = 5
UITabBarSystemItemHistory = 6
UITabBarSystemItemBookmarks = 7
UITabBarSystemItemSearch = 8
UITabBarSystemItemDownloads = 9
UITabBarSystemItemMostRecent = 10
UITabBarSystemItemMostViewed = 11
setBadgeCountAtIndex(badgeCount, index)
sets badges count for tab at given index (small red circles shown on top of tabs)
selectTabAtIndex(index)
selects tab at given index
getTabPotionsArray()
returns javascript array of tab pageNames sorted in order as user reordered them having "more" tab, used to save the positions of rearranged tabs and be able to restore same order on next application launch.
setMoreBarTintColor(red, green, blue)
sets color of the navigation controller which appears when "More" tab pressed (if you have more then 5 tabs "More" tab will appear automatically).
setOnTapCallback(callback)
sets callback to be called when user taps on tab bar, callback format is following callback(pageName), where pageName is the name of the page been taped.
getSelectedTab()
returns a file name of currently selected tab, for instance "main.html"
setTabForPageDisabled(page, disabled)
sets tab disabled or enabled
page - page name of tab you want to set state for
disabled - state you want to set. pass true or 1 to disable, false or 0 to enable
Example:
var tabController = new NKTabBarController;
var settings = new NKSettings;
var array = settings.getValueForKey("tabOrder");
if (array.length>0) {
for (i=0; i<array.length; i++)
tabController.setTabBarForPage(array[i], array[i], "");
}
else {
tabController.setTabBarForPage("main.html", "main.html", "");
tabController.setTabBarForPage("1.html", "1.html", "");
tabController.setTabBarForPage("2.html", "2.html", "");
tabController.setTabBarForPage("3.html", "3.html", "");
tabController.setTabBarForPage("4.html", "4.html", "");
tabController.setTabBarForPage("5.html", "5.html", "");
tabController.setTabBarForPage("6.html", "6.html", "");
}
function OnApplicationQuit()
{
array = tabController.getTabPositionsArray();
settings.setValueForKey(array, "tabOrder");
}


