For an iPad Application developed using Appcelerator Titanium SDK 3.1.2, I have a Ti.UI.Tab Group which contains 5 Ti.UI.Tabs. Each Tab contains a Root Ti.UI.Window and certain tabs open additional windows when relevant.
When you double tap any of the Tabs in the Tab Group, the Tab double tapped will reset its content to the Root Window, automatically closing windows inside it that were open.
I want to disable this from happening, but there is no property for either the Tab Group or the Tab itself that allows me to prevent the double tap from occurring.
An alternative to creating your own TabGroup Control using Views, is to add a NavigationGroup Control inside the Tab where you want to prevent resetting of Windows when a double tap occurs on the Tab.
In your Tab Control for your TabGroup, create an empty Window Control and link it to your Tab as you would normally do. Then, create a NavigationGroup Control and add it to the Tab's root Window:
//Set up your Tab Group with a Tab and a Root Window for the Tab
var tabGroup = Ti.UI.createTabGroup();
var tabWin = Ti.UI.createWindow({
navBarHidden:true
});
var tab = Ti.UI.createTab({
window:tabWin
});
tabGroup.addTab(tab);
//Create a Root Window Control for the Navigation Group
var navWin = Ti.UI.createWindow({
title:'NavGroup Root Window'
});
//Create a NavigationGroup Control and add it to the Root Window
var nav = Ti.UI.iPhone.createNavigationGroup({
window: navWin
});
tabWin.add(nav);
//Launch Tab Group
tabGroup.open();
When you open Windows inside this tab, instead of using the Tab.open(Window) method, use the NavigationGroup.open(Window). Let the NavigationGroup manage the Window Stack instead of the Tab:
//Open a new Window inside the Navigation Group
var win1 = Ti.UI.createWindow();
nav.open(win1);
//Close this Window you opened
nav.close(win1);
By doing this, you prevent the Window Stack from resetting when users double tab the relevant Tab that contains the NavigationGroup Object.
I encountered a similar problem before.
End up I compose my own tab bar to do the tab switching. So that whenever a tab button is clicked, I can get the tab event and do the checking.
Hope it helps.
Related
I am developing an application in which few of the screens open up through the tabs in the Tab Bar but some of the screens don't open from there. They open up from Hamburger View.
Could anybody please help me understand if its possible to show the Tab Bar at the bottom of the screens that don't open from there? My requirement is to show the tabs at the bottom of all the screens whether or not they open from the Tab Bar. Is this possible?
Regards,
Kavita
If the tab bar is hidden, then use this:
self.tabBarController.tabBar.hidden = NO;
Even if screens are not opened from any item in your hamburger view, instead of pushing or presenting that screen, you can just programmatically switch tab, hence tab bar will remain always.
For eg: you have 3 tabs showing screen1, screen2, screen3.
Now if you want to open screen3 by clicking on a menu in hamburger view, just set tabbarcontroller.selectedIndex = 2
Using Xamarin Forms, I have a MasterDetailPage whose Master is a list of menu options and Detail is a NavigationPage that contains a ContentPage. If I push a second page onto the Detail's NavigationPage, the icon that used to open the menu becomes a back button. I want to override this behavior so that icon always opens the menu. I have a subheader with a custom back button which is why I need the Detail to be a NavigationPage.
It's not possible out of the box. maybe using a custom render for the Navigation page.
This is possible now
NavigationPage.SetHasBackButton(page, false);
where page is the page you are about to push.
I found there are a lot of ways to make a new screen pop up with the Master Detail Page. The one that stopped the back button from showing up for me was:
((MasterDetailPage)Application.Current.MainPage).Detail = new NavigationPage(page);
where "page" is whatever screen you want to set it to. For example:
((MasterDetailPage)Application.Current.MainPage).Detail = new NavigationPage(new ResultsPage());
I created a tab bar application with storyboards.
Regardless of which tab is selected, I want to activate a specific tab when an event occurs (such as an error).
I have tried the following example but with no success:
[self.tabBarController setSelectedIndex:0];
Is there another way to manage that?
I have some specific question:
My application have 4 tabs with independent navigation controllers under each of it.
Let's say tabs are: "Recent", "Chat List", "Contact" and "Settings". Sometimes I need to open the "ChatView" controller from different tabs and places, like "Contacts" or "Recent". "ChatView" is located under "Chat List" tab (root controller is "ChatListView") and usually is displayed after selecting some existing conversation (in navigation stack it's like ChatListView -> ChatView).
I want to find the best way, how to open the "ChatView" controller with switching to the "Chat List" tab and reseting navigation history, so when user see the "ChatView", the back button we'll turn him to the "ChatListView", but not to "Contact" or some other place where he stayed before. Modal view will not work in this case, because I need both tab bar and navigation bar displayed.
Thank you for your advices!
Update
Also please note that I need to pass some data to the newly opened ChatView controller. Just switching selected tab bar also is not enough, because I need to open View under its root controller (ChatListView -> ChatView)
For this you can use setSelectedIndex property of UITabbarController.
You could implicitly change tab to show by using selectedIndex property.
Try this:
NSInteger indexOfChatsTab = 1;
UINavigationController *chatsNavigationController = tabController.viewControllers[indexOfChatsTab];
[chatsNavigationController popToRootViewControllerAnimated:NO];
[chatsNavigationController pushViewController:selectedChatViewController animated:NO];
controller.selectedIndex = indexOfChatsTab;
Update:
selectedChatViewController from above example is view controller that initialized by necessary data for displaying new chat.
I mean that before pushing you need initialize it like this:
ChatViewController *selectedChatViewController = [[ChatViewController alloc] initWithChatData:chatData];
I need to create a navigation in iOS app like following screenshot.
It contains a Tab Bar and a Side menu.
The problem is the right navigation menu button, should be visible in all tabs. Even all inner screens of each tab.
When user selects an option from side menu, it should be displayed on screen.
Now each tab should be accessible from each option item, and each option menu should be accessible in each tab. Its like a many-to-many relationship in DB.
How should I design it?
I have tried following so far.
Within each tab, there is a containerViewController. Which consists of my FrontViewController and SideMenuViewController.
When an option is selected from side menu, a message is passed to containerViewController which removes the old FrontViewController from view and adds new OptionViewController.
The menu button and navigation bar is added in containerViewController, so that if should be visible every time, at any screen.
Problems
Now facing some problems using this approach.
As the navigation bar is added in containerViewController. I have access it using parent property of my FrontViewController. Suppose if I need to use PushViewController in my FrontViewController, I have to use parent property. Like this
[self.parent.navigationController pushViewController:newVC animated:YES ];
[self.parent.navigationController popViewControllerAnimated:YES];
I have to use this approach within each tab. Means code is repeating 5 times.
Can anyone suggest a simple solution. Any help is appreciated.
You can try to use InteractiveSideMenu for your purpose. It supports interactive opening/closing menu and following customization:
Animation duration
Visible content width
Content scale
Using spring animation with params customization
Animation options like animation curve
You should use 3 basic ViewControllers for creating subclasses for implementing your side menu.
MenuContainerViewController is a host for menu and content views
MenuViewController is a container for menu view
MenuItemContentControlller is a container for content that corresponds menu item
Here is an example of setup Host controller.
import InteractiveSideMenu
class HostViewController: MenuContainerViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.menuViewController = self.storyboard!.instantiateViewController(withIdentifier: "NavigationMenu") as! MenuViewController
self.contentViewControllers = contentControllers()
self.selectContentViewController(contentViewControllers.first!)
}
private func contentControllers() -> [MenuItemContentViewController] {
//here is instantiation of content view controllers
}
}
I would think about subclassing UINavigationController and adding your button management logic there. When any view controller is pushed into the nav controller, set its bar button item.
The side menu shouldn't be inside each tab. Your root view controller should really control the main and side views and the main view has your tab controller which has a navigations controller as the root of each tab.
Now that the navigation bar doesn't need to be managed by a different container controller things become easier.
Bar button actions push up to the root view controller only, a reference to it can be set when the navigation controllers are created. Option selection would traverse root VC -> main (tab) VC -> selected tab nav controller -> push.
It could be easier to use a cocoapod for iOS side menus such as APMultiMenu. I've used it and it's simple to use and follow