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.
Related
In my app's main view, I have a button that segues to a subclassed UINavigationController holding a UITableViewController to change settings.
To get back to the app's main view, I have this in the UINavigationController subclass:
navigationBar.setItems([UINavigationItem(title: "Back"),
UINavigationItem(title: "Settings")],
animated: false)
When I tab the Back button, the app segues back to the same view - but the navigation bar now only have the Settings item.
When I click the Back button, I want to dismiss the UINavigationController subclass and come back to my main view.
So how do I get a touchUpInside event on the UINavigationItem or is there some other way I can do this?
So it turns out there's a very easy way of doing this:
adding a UIBarButtonItem in the storyboard
subclass the UITableViewController
control-drag from the UIBarButtonItem to the UITableViewController subclass to create an action
dismiss the UITableViewController in the action
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];
I have the next structure:
* TabBarController
- ViewController with TableView
- ViewController
When I select any row on the TableView, the segue forwards me to the ViewController. On the ViewController with the TableView, I see the BottomBar, but after the segue it disappears.
How can I keep it on my ViewController? I've even putted the last ViewController in NavigationController, but it did not help me, too.
How can I fix it?
Your hierarchy should look like this:
* TabBarController
- NavigationController
- ViewController with TableView
- ViewController
Using a Show segue with an UINavigationController pushes the destination view controller onto the navigation stack. However, most other view controllers present the view modally (i.e. by sliding over the source view controller) with Show, which is why your tabbar disappears.
uncheck hide bottom bar when pushed from your view controller in story board
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]
}
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