I have a starter UIView and if user clicks the button in starter view present a tabbar model view. In that view, I have a tab bar controller with 4 items as the first one "Home" tabbar item where if user clicks it dismisses the tabbar controller view and go back to the start view (so when tabbar view is loaded it starts with the second tabbar item). My question is: how can I dismiss the tabbar controller when user clicks the home tabbar item.
Ehm I think this is against guidelines and would advice you to try a different approach. However, you could make the home button load a view which class has [self presentModalViewController:starterViewController animated:NO]; in viewWillAppear
Related
I'm creating a tab bar application using the built-in tab bar app template in Xcode. I have 4 tabs, one of which is a mapView. For a few of the view controllers my code programmatically sets the selected index of the tab bar depending on the user actions. For the mapView view controller I have a method that presents a modal view when the user taps on a selected annotation. The modal view has some information about that selected annotation. I can dismiss the modal view controller and return to the mapView correctly.
My problem is that I would like to put a 'home' button on the modal view controller that should dismiss the modal view and take the user to 0 index on the tab bar (AKA home). The mapView is index 3.
I cannot do a [self.tab setSelectedIndex:0] from the modal view attached to the home button - it doesn't work. Perhaps I'm overthinking this. Can anyone offer a solution / hint? I greatly appreciate it! Thanks.
When you present a modal view controller from one of the tabs, the tab bar controller instance becomes the parentViewController of the modal view controller. You can use this property to call the tab bar controller methods.
[(UITabBarController *)self.parentViewController setSelectedIndex:0];
I have a simple uiviewcontroller with 4 buttons. Every buttonclick event loads a different image on the view. However for the 4th button i want to launch a navigation controller based uiview with a uitableview. The table view can then have 3 levels which define the settings for the application.
On selecting a row in the uitableview on the 3rd level i need to return to my main view with the selected row index.
How can i add a navigation based view which will be launched on a button press event and the first view of the uinavigationcontroller should compose of a back button which will close this navigation view and return to main view.
TIA,
Praveen S
Edit:
My first(home) view does not need a navigation bar. The view launched from the home view should however consist of a navigation bar with back button.
if(nxtv12==nil){
nxtv12=[[v12 alloc] initWithNibName:#"v12" bundle:nil];
}
[self.navigationController pushViewController: nxtv12 animated:YES];
and for coming back to home.
[self.navigationController popToRootViewControllerAnimated:YES];
Create a UINavigationViewController object in the current UIViewController (or use self.navigationcontroller) and push the new UIView into the navigation controller. To come back to the same view, use popToRootViewControllerAnimated in the new UIView class.
after reading a lot of tutorials and threads here on stackoverflow there is one basic question left in my head.
The structure of my App should be the following:
MainMenu - fullscreen without a navigation bar but 2 buttons (button1 and button2)
Page1 - should appear by pressing button1 and should have a navigation bar at the top with a "back"-button to get back to the MainMenu.
Page2 - should appear by pressing button2 without a navigation bar at the top. Page2 should be a UISplitView. There must be a back button somewhere.
(I think this is where the problem starts, a UISplitView can't be presented modally, can it?)
You should be able to add subpages to Page1.
So how can I do that? I don't need executable code but just a hint on how the structure of my app should be. For example where to add the navigation controller, how the MainMenu looks like.
Thanks in advance!
Are you trying to create an Application for iPad?
Your Application's UI sems inconsistent being First View the only view without navigation Bar.
You will be using standard navigation to navigate to page1 from home page. So you will be adding a navigation Controller with Home View Controller as a Root View COntroller with hidden navigation bar.
eg.
-(void)applicationDidFinishLaunching:...
{
HomeViewController * hvc = [[HomeViewController alloc]init];
UInavigationController * nvc = [[UINavigationController alloc]initWithRootViewController:hvc];
nvc.navigationBar.hidden = YES;
[window addSubView:nvc.view];
}
Then on tap of first Button you will be pushing the Page1 View Controller
-(IBActtion)button1Pressed:(id)sender
{
Page1ViewCOntroller * p1vc = [[Page1ViewCOntroller alloc]init];
[self.navigationController pushViewCOntroller:p1vc animated:YES];
}
In viewWillAppear: method of Page1ViewController unhide the NavigationBar and hide it in the viewWillDisappear: method
Your Page 2 needs to be splitViewController.
Now about Split View, Apple says
The split view controller’s view should always be installed as the root view of your application window. You should never present a split view inside of a navigation or tab bar interface.
But as there is no "must" written in the above statement, and since its finally a View Controller in itselt, you should be able to add it on the window or another view.
Try to create a VIewController, with split VIew added on it, and like page1, push the View on the navigation Controller.
I have a simple tableview that navigates to a detailed view with a navigation controller. In the detailed view I need to create a button which when pressed isolates all other buttons displayed on the screen including the navigation controller back button. I know how to get the invisible button to cover most of buttons the screen but I can't get it to cover the navigation controller back button as this has been created in the parent view. How do I pop it over the top of the navigation controller from the detail view?
You can insert the button as a direct subview of the key window.
[[UIApplication sharedApplication].keyWindow addSubview:theButton];
(why not use an UIAlertView or UIActionSheet?)
I have an application with a Tab Bar Controller that has three tabs.
In tab 1 there is a view (view1) with a button that when clicked transitions the user to a new view (view2) still within tab 1. However when this new view (view2) is loaded it covers my tab bar controller.
What is the best approach for me to take to still display tab bar controller as well as keep tab 1 highlighted?
How are you performing your "transition" to view2 from view1?
One solution is to use a UINavigationController as the root view controller for tab1, so view1 can display view2 by pushing it on the navigation controller. Alternatively, have view1 display view2 modally.
Either way should not cover your tab bar, and tab1 will still be selected (highlighted).
I think you are pushing the view as modal view if this is the case then the view will definitely cover your tab bar the other way to do this is push the view controller and this will not hide your tab bar.
Try to do it like:
[[self navigationController] pushViewController:viewContObject animated:YES];
Hope this helps,
Thanks,
Madhup