how to dismissModalViewController by clicking tabBarItem - ios

When i didSelectRowAtIndexPath in my tableView, my DetailView is loaded. In detailView i can return to the tableView with a backButton, which dismisses the detailview.
In My app i have in front a tabBar (tabbarcontroller), everytime. When the detailView is loaded and in case of the backbutton is clicked a tabBarItem, the detailViewController is not dismissed.
That means, that i cant load the detailView again, if i didSelectRowAtIndexPath.
Can someone help my out with this problem?
Thanks,
brush51

The UITabBarDelegate protocol has a method called tabBar:didSelectItem:. You may use this method to detect when an UITabBarItem was selected and then call a method to dismiss the detailViewController.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarDelegate_Protocol/Reference/Reference.html

Related

Double tap on UITabbarItem to reload Viewcontroller/UITableView

I'm using UITabbarController in my project. All viewControllers are loading properly and the navigation from parentViewController in UITabbarController to a childViewController and then back to parentViewController when tabbaritem is tapped is working.
Now I want to reload the parentViewController if the user tap on the UITabbarItem while the parentViewController is already visible.
I'm not using and don't want to use viewwillappear method to reload the viewcontroller which will not work here in this case anyways as the view is already visible.

segue to the TabbarController

In my image, my first Tabbar is HomeViewController and the second Tabbar is CameraViewController.
What is the proper way to segue to the Tabbarcontroller? You can see the read line, I try to segue this but I
always get the back button in my HomeViewController and It display weird like not showing the navigation name.
In CameraViewController I hide the Tabbar for the use camera button. I try to use segue programmatically like this one.
[self performSegueWithIdentifier:#"sample" sender:sender]
but It doesn't work properly. Is this possible to segue to TabbarController?
You can't call
[self performSegueWithIdentifier:#"sample" sender:sender]
Because you're in TabBarController already. You could implement custom flow. By pressing "Back" button - just show TabBar and change selected tabBarItem for example…
update
used this
[self.tabBarController setSelectedIndex:0];

popViewController not working with storyboards

I create a UINavigationController (as a initial screen) and connect them with my UITableViewController (as a root).
Next, I create another UINavigationController and connect with my UIViewController. Inside my UITableViewController I connect my first cell with UINavigationController (That was connected with my UIViewController) (Segue -> show).
When I run the project my table appears, when I select my first row, my UIViewController appears. Thats great!
When I was in my UIViewController the back bar button doesn't appears, in my case I create a left bar button, that will run a function to dismiss that view and go back to my UITableViewController, for that I use many codes:
-(void)back{
NSLog(#"Called");
[self.parentViewController.navigationController popViewControllerAnimated:YES];
}
-(void)back{
NSLog(#"Called");
[self.navigationController popViewControllerAnimated:YES];
}
-(void)back{
NSLog(#"Called");
[self.navigationController popViewControllerAnimated:YES];
}
But all of they doesn't works and my view don't dismiss, how can I solve this problem?
The problem is that your navigation controller, that you call from your table view cell, has only a single view controller (yours) on its navigation stack. So it cannot pop anything from this stack, else the stack were empty.
What you have to do instead is to dismiss the navigation controller itself.
I think that the solution would be to remove the second navigation controller. Since the TableView is already embedded inside a Navigation Controller, the show segue to the UIViewController must be directly connected to it.

Reload a tab after dismissing a view

There are two views in a tabbarviewcontroller. And the first tab has its view controller called myViewController which contain its IBOutlet. Pressing the button on the first view will present a view controller. After dismissing the view and back to the tab, the viewWillAppear of myViewController won't be called,but viewWillAppear of tabbarviewcontroller will. I need to reload the information on the first tab. If I use viewWillAppear in tabbarviewcontraller, how do I change the values of these property in myViewController? If anyone has idea ? Thanks.
If you want to call viewWillAppear of the viewController, you can add this to viewWillAppear of the TabBar
for (UIViewController *viewController in tabBarController.viewControllers)
{
[viewController viewWillAppear:YES]
}

UIPopover in storyboard

I have a UIViewcontroller, with a button. When I press the button it triggers a segue to a popover view (the segue is set through storyboard, not through the codes). When the popover is dismissed (by pressing outside of its bounds), I want the initial view controller to reload. how can I do that?
You can set the delegate of the popover controller in your prepareSegue: method and implement the delegate method popoverControllerDidDismissPopover: which will be called when the popver is dismissed.
You can get the popover controller with UIPopoverController *popover = [(UIStoryboardPopoverSegue *)segue popoverController]

Resources