UITabBar item did select is not working - uitabbarcontroller

i have two tab bar items with two different table view with navigation controllers.
by clicking on the tab1--- table1 is opening...Good. but when i did select on table1 it goes to the another view (table did select view)....every thing is good.
but the problem here is
when i am clicking on tab2 ----table 2 is opening....Good.
But again clicking on tab1------ it is not loading the table1....it is loading (table did select view) view. As the last time i left it there.
i want to open table1----on clicking on tab1......by programming.
help me

That is the expected behaviour if you are using the tab bar controller and the navigation controller in the item of the tab bar. User will expect the tab to retain the state of the view.
If you still want to enforce the app to go back to the root view controller of the navigation controller when user goes back to the tab, you can implement the UITabBarControllerDelegate tabBarController:didSelectViewController: method. What this delegate method does is:
Tells the delegate that the user selected an item in the tab bar.
Then call the method of UINavigationController called popToRootViewControllerAnimated: when user tap on the tab. This will help you to:
Pops all the view controllers on the stack except the root view
controller and updates the display.
For example:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if(viewController == yourNavigationController) {
UINavigationController *navigationController = (UINavigationController *)viewController;
[navigationController popToRootViewControllerAnimated:NO];
}
}

Related

Is there a way to update the NavigationTitle of a NavigationView from a button in it's detail view?

I have a NavigationView showing a title with the number of records in a List:
.navigationTitle("\(navBarTitle) (\(String(numberOfRecords)))")
In the toolbar I have 2 buttons:
show Unread - only show unread / show all
show Favorites - only show favorites / show all
The List view shows either All records, Unread records or Favorite records. Switching between Views using the buttons works fine and updates the navigation title numberOfRecords variable.
All is well sofar. Now...
Rows in the list have a NavigationLink that goes to a detail view:
NavigationLink(destination: detailView(record: record))
In the detail view I have a button: make card favorite. I click the button, but when returning to the list view, the numberOfRecords variable in the navigation title is not updated.
How can I update the navigation title from its detail view?
Thank you!

How to add a right button when specific UIViewController get loaded in Swift 3

I have two different UIStorboards and I am using a UINavigationController to load the pages.
I have a total of three UIViewControllers. Two of them are on the first UIStoryboard and the third one is on the second UIStoryboard.
1) Navigation controller
2) Main Controller
3) Value Screen Controller.
I want to add right button on navigation bar only when value screen controller get loaded. It should not be available on Main view controller.
I tried with this solution but not worked.
Each UIViewController has its own UINavigationItems. So you can just add this right button in your Value Screen Controller by adding this line:
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: <#T##UIBarButtonSystemItem#>, target: <#T##Any?#>, action: <#T##Selector?#>)
You can place it in func viewDidLoad() if you want it to be place as soon as the UIViewController's view is loaded.

Return values from ionic2 modal to parent page

I am opening a Modal in ionic2, to search the values from a list. After search, I want to get the selected values back in my parent screen.
searchRooms(){
let modal = this.modalCtrl.create(RoomSearch);
modal.present();
}
This opens my search Modal and there I have list of available rooms. If user click on any room then I want to return back the value to parent page. I am not sure how to do this.
From documentation I feel NavConroller.pop can be used to pass back the values but I don't know how to use that.
Thanks in advance.
You can use onDidDismiss method explained in the Modal Controller.
In the page that opens your modal you can do :
let modal = this.modalCtrl.create(RoomSearch);
modal.onDidDismiss(data => {
// Do things with data coming from modal, for instance :
console.log(data);
});
modal.present();
And this in your modal controller, to close the modal :
this.viewCtrl.dismiss({"foo" : "bar"});

How to add a navigation bar to UITabBarController?

Im trying to add a navigation bar to all view controllers inside my tabbarcontroller. Do I add the nav bar to individual view controllers...
or
Is there another way?

Sencha Touch 2: Multiple instances of a NavigationView (one for each tab) : every panel pushed by controller opens in first tab

In my sencha touch app i have a NavigationView container which loads a panel view containing a list rendered from a store.
I have a tab-bar in which each tab opens this NavigationView container adding, depending on which tab is tapped, some extraparams in the store used by the panel view inside the NavigationView container.
This is working OK and for each tab i get the NavigationView container and inside it the panel view containing the right list for that tab.
The problem is these lists have some child lists that need to be loaded when tapping a list item. I do this using the following controller that pushes in the NavigationView container another view Panel containing the child list:
Ext.define('FirstApp.controller.Details', {
extend: 'Ext.app.Controller',
config: {
refs: {
// this is my NavigationView container
placesContainer:'placesContainer'
},
control: {
'placesContainer categorie list':{
itemtap: 'chooseCategory'
},
And my chooseCategory function is:
chooseCategory:function(list,index,target,record){
//these add some extra params to my store's proxy
Ext.getStore('Articoli').getProxy().setExtraParams({ catid: record.data.id });
Ext.getStore('Articoli').load();
this.getPlacesContainer().push({
// this is the target view panel
xtype:'articoli',
title:record.data.title,
data:record.data
})
}
And this works very well but when you click on a list item, its child list is pushed inside the first tab panel.
Example: i tap on the 3rd tab. The app shows the list corresponding to the 3rd tab. I tap on one of the list's items. The app loads its child list in 1st tab panel. I cannot see any changes until i tap on the first tab. There i can see loaded the child list of tab 3.
You can give onDisclosureItem:true to your list and in the controller give an disclose event so that on disclose it would load the sub categories and on item tap it would navigate you to the other view
'placesContainer categorie list':{
itemtap: 'chooseCategory',
disclose: 'openSubCategory'
},