Add button "More" to show another button on UITabbarcontroller - iphone

I want to show more 2 "button" when touch in a tab on "UITabbarController", how can I do that.
I use UIActionSheet but when I call
[choiceSheet showInView:[self.view window]];
[choiceSheet showFromTabBar:[[self tabBarController] tabBar]];
it show UIActionSheet but still catch excepton.

As soon as there are more than 5 viewControllers inside a tabbarcontroller, the fifth entry becomes 'More...' and a list of the remaining view controllers is shown
This is the intrinsic behaviour of the UITabbarController

Related

TabBarController called by a TableViewCell in another TabBarController

I was wondering if it is possible to have the following:
One TabBarController with two buttons containing a UITableView in each one.
Then, if one of the TableView cells is clicked, I would like to push to a new TabBarController with a different set of 4 buttons containing other table views.
Can anyone point me in the right direction?
The first thing I tried was set up the first TabBarController with the UITableView under each button. But when I added the second TabBarController to be triggered from a clicked tableview cell, what I got was the first Tab which contains the 2 buttons, and on top of that, the second tab containing the 4 buttons.
I would like the second TabBarController to replace and leave behind the first one.
I hope I explained myself well enough, thank you for your time.
You should change your push segue to a modal segue.
To go back you are going to need to implement a return button in your destination viewController:
- (IBAction) dismiss:(id)sender
{
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}
(note that you must do this in code - you cannot draw a segue line to go back)
At the moment you must have a navigation controller involved in your push segue. When you change to a modal segue you can remove the navController, it won't play a part in the navigation.

Multiple instances of the same TabBarController after Modal Segue iOS

I have an app with one main TabBarController containing two tabs that control two different views, A & B. View A is a scrollView and View B is a TableView. When i initially load the app, the scrollview in view A is empty.
In order to add pages to my scrollView, I have set it up as follows: I go to view B and perform one modal segue to a view embedded with a navigationBar. The navigationBar only has one button, 'Cancel', which I use to dismiss the view. Otherwise, the user must click on an image an perform another modal segue to a different view. This view has no navigation bar, and has one button 'DONE', which I use to perform a modal segue back to the initial tabBarController.
Here's the problem: the page is added to the scrollView with no errors after I press 'DONE'. However, I believe I now have two instances of the same tabBarController floating around in memory. When I attempt to grab the views contained in the scrollView with a different button, it tells me that it is now empty (even though it was full during viewDidLoad and viewDidAppear).
How can I remove the initial tabBarController view or otherwise how can I segue back to the tabBarController that I have already allocated? Any help would be extremely appreciated! Thanks!
You shouldn't do a segue back to the original view controller. Rather, you should dismiss the current view controllers animated, and show your original tabBarController.
Inside the view you were segueing back from, add:
tabBarController *tabs = (tabBarController*)[[self presentingViewController]presentingViewController];
tabs.selectedViewController = [tabz.viewControllers objectAtIndex:0];
[[[self presentingViewController] presentingViewController] dismissViewControllerAnimated:YES completion:nil];
Then you will have the view A appear and still use the same allocation.

Navigation Issue with UITableView

How do I navigate back to the previous page with a UITableViewController. I tried to show a navigation bar with navigation button at the top of the screen, but the navigation bar will not show. I know that you have to give the previous view a title but when I go to do that it does not show anything. Also, since it is a UITableViewController I am not able to drop a navigation bar and add a button to the main view. All I would like to do is display my lists and have the option to navigate back to the previous list with a single button in the upper left corner.
The problem you having with the NavigationController is that your tableViewController is not in the NavigationController hierarchy. Want you want to do this when adding the tableViewController:
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:yourTableViewController];
Then you can do this to add yourTableViewController:
[self.view addSubview:navigationController.view];
If you don't want the navigationBar to appear on the tableViewController just use:
self.navigationController.navigationBarHidden = YES;
in yourTableViewController viewWillAppear method.
When your going to add the view after the tableView you just use:
[self.navigationController pushViewController:someViewController animated:YES];
It's not enough to give the child view a title. You need to give the child view's navigation item a title before you present it. For example, in the parent view, before you push the the view to the navigation stack, do something like this...
[MyChildView.MyNavigationItem setTitle:#"A cool Title"];
For the navigation you are trying to achieve you should be using a UINavigationController. It already has the functionality you describe with the navigation bar and back button built into it.
To move to the next screen (which can be a UITableViewController) you use pushViewController:animated: and to move to the previous screen you use popViewControllerAnimated: (although the built in back button will do this for you).
I suggest reading the UINavigationController class documentation if you are not already familiar with it.

How i calling UITableViewController in UITabBarController screen using Navigation bar on button click in iphone?

My i have to develop simple window based iphone application.
In my first screen I design the UITabBarController with four TabBarButton.On first Tab screen contains three buttons.
When i click on of the button, the screen should navigate on simple tableView screen.But tableView screen the TabBarController should have be visible. Means simply first replacing with table view and move back to again previous one(The UITabBarController should be visible on all srceen).
Wrap your root view controllers in UINavigationControllers. Then, add the UINavigationControllers to the UITabBarController (so there should be 4 UINavigationControllers, one for each tab). When the button is clicked in the original view controller, do something like:
-(void) buttonClicked {
SimpleTableViewController *tvc = //etc
[self.navigationController pushViewController:tvc animated:YES];
[tvc release];
}

How to hide back button in the first view on iPhone?

I add 3 views for an application and they need to switch from 1-2-3.
Now I add a toolBar and a button 'OK' on the bottom of SwitchViewController, so they can share the button to go to next view.
But how to add a 'Back' button so that I can switch from 2-1 or 3-2 and the button shouldn't be seen in the first view?
Are there any other ways to switch views without sharing the same tool bar button?
It sounds like what you're trying to do is use a UINavigationController. If you instantiate a UINavigationController with the initWithRootViewController initializer you can pass it your first UIViewController. Then you just need to tie whatever action you want to a method that calls [myUINavigationController pushViewController:myOtherViewController animated:YES] to get it to slide over to the second view. The UINavigationController will automatically set up the UINavigationBar and back button you are looking for.