How to make UIView go fullscreen when entering edit mode - ios

I have a UITableView that renders in the context of a UINavigationController (and maybe even a TabBarController). There is a way to make the UITableView enter editing mode. When that happens I want the table to get 'focused' and the navigation bar and tab bar to go away (the table view has to expand to fill the empty space). Then when editing mode completes, it should all go back to normal. Anyway to achieve this with standard iOS view and controller functionality. Or do I have to start hiding controls and resizing the view manually?

You could use a modal view to accomplish this.
Have a look at the documentation for [UIViewController presentViewController:animated:completion:]

If you just want to show the UINavigationBar and the UITabBar to disappear, you can just use:
[self.navigationController setNavigationBarHidden:YES animated:YES];
Otherwise, you can show an editable version of the UITableViewController and push it onto the navigation stack:
viewController.hidesBottomBarWhenPushed = YES; // this property needs to be set before pushing viewController to the navigationController's stack.
[self.navigationController pushViewController:viewController animated:YES];

Related

Weird animated on pushing controller hiding tab bar and adding a toolbar

I have an app with the hierarchy of UITabBarController > UINavigationController > UIViewController. Currently if you tap on the collectionView's cells it performs a segue to show the full size image. I have the view controller that is being pushed setting the hidesBottomBarWhenPushed property to YES. Then in viewWillAppear: on the view controller being pushed, I am calling [self.navigationController setToolbarHidden:NO animated:NO] and as you can see in the animated below the bottom left of the screen is present from the previous screen.
Change ur code to this: Set animated YES.
[self.navigationController setToolbarHidden:NO animated:YES]
So it turns out that I had to have the view controller being pushed go under the bottom bar otherwise it gave the weird animation. When I did that everything went back to normal. I then also animated the call to setToolbaHidden:animated: as suggested above.

Safe way to remove tab bar from UITabBarController in ios

I want to use UITabBarController but I do not need a tab bar because I'm going to switch tabs from the menu in another view controller. I want to remove it as it will be never used. I've created a subclass of UITabBarController and put this code:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tabBar removeFromSuperview];
}
Is that safe to remove tab bar that way?
Update: Why tab bar controller?
Apple suggests to use standard container view controllers whenever it possible. I'm trying to follow that. My screens workflow is the same as for tabs, except that they are switched by left side menu, not by the tab bar.
When I use a UIViewController and change it's child view controller I've got a lot of problems when autolayouts are not working properly.
The other reason is that I want to use story board, rather then create segues from the code so I can see my app workflow easily.
When you are saying, you don't want to use it, then why to remove it. You can go with a
tabbarcontroller with hidden tabbar. I am switching tabs from the bottom custom bar.
I am doing an app, which has a tababr controller with three items. Instead of using system tab, I am creating a custom view at the footer like tab & have actually set the hidden property of tabbarController's tabbar to YES.
myTabBarController.tabBar.hidden = YES;
Try this code
[app.navigationController.view removeFromSuperview];
[app.tabbarcontroller.view removeFromSuperview];
[app.window addSubview:app.navigationController.view];
[app.navigationController popToRootViewControllerAnimated:YES];

pushViewController without navigationcontroller

I have a class that is of type UITableViewController.
This class has a member of type UINavigationBar that I use for adding in an edit button for the table view.
Using this method calling is invalid.
[self.navigationController pushViewController:controller];
How can I push a detail view onto the view after selecting a table row without wrapping my UITableViewController in a UINavigationController?
The closest alternative if you don't want to use navigation controller are modal view controllers.
[self presentViewController:controller animated:YES completion:nil];
This will slide the controller into your screen from bottom, or if you change controller's modalTransitionStyle it can flip over or fade in.
To dismiss the controller just call:
[self dismissViewControllerAnimated:YES completion:nil];
I would wrap the UITableView inside a UINavigationController and just hide the UINavigationBar.
[self.navigationController setNavigationBarHidden:YES animated:NO];
And then create a back button that pops the ViewController off the stack.
[self.navigationController popViewControllerAnimated:YES]
What could also be done is to use a Navigation Controller as usual and then hide it.
To hide the Navigation Controller using storyboards: select it and uncheck "Show Navigation Bar" in the attribute inspector. Others might suggest to hide the navigation bar in each controller, but the problem with that is that it will appear for a millisecond and then disappear.
You can't push a view controller onto a navigation controller if there is no navigation controller. If you are wanting to be pushing controllers and have it display the topmost controller and everything, just use a UINavigationController and be done with it.
You can push arbitrary UINavigationItems onto your UINavigationBar, and your bar's delegate will be notified when the user uses the back button so you can take appropriate action. See the documentation for more information.
It's true that without a UINavigationController you can not push view controllers. You rather present view controllers modally via UIViewController.present(_ viewControllerToPresent:, animated:, completion:)
But it's possible to create a custom segue to display the view controller as if it were a push (or any other animation you want), although it seems that using a UINavigationController just makes things easier.
Here are some related links to the documentation:
UINavigationController Class Reference
Customizing the Transition Animations
Presenting a Modal View Controller

TableViewCell disappears when push UINavigationController in UITabBarController's More tableview

I add 6 navigation controllers to UITabBarController's viewControllers. As normal, a More tab is created to list the last two. The problem is: after I select a table cell in the More table view, that cell's content fade out and disappear before the view controller push in. And then, after I back to the More table view by click the Back button, that cell's content show again. I guess the reason is More table view in its own navigation controller, and it push another navigation controller (created by me). I don't want to remove my navigation controller because I want to allow user rearrange tabs using the UITabBarController's Edit function. Can anyone suggest what I should do?
Create instances of your 6 navigation controllers in AppDelegate and retain them. And release in dealloc method
Just had the same problem. In my case I accidentally assigned the tabBarItem to the VC inside the navigation controller. When I instead initialized the tabBarItem on the navigation controller, the flickering / disappearing stopped.
MyViewController* viewController = [[MyViewController alloc] init];
UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewController release];
// this has to be navigation.tabBarItem (not viewController.tabBarItem)
[navigation.tabBarItem initWithTitle:#"Title" image:[UIImage imageNamed:#"fancy.png"]
tag:42];
Initializing the tabBarItem on the viewController still showed the icon which made it harder to discover. I'm also not very sure (actually I think it's bad) about the way I initialize the tabBarItem (without alloc). But I had troubles with disappearing icons etc and hey, it works ;-)

UINavigationBar moves my view

I have a UINavigationBar that is hidden most of the time my app is running.
however when i was it to show i call
[navigationController setNavigationBarHidden:NO animated:YES];
the view currently showing is resized..
i then unchecked the "auto resize" option in interface builder.
now the view is moved down.
i there a way to load the navbar over the top of the view so it does move my view?
Many thanks
You need to put your own navigationbar by picking from the Library.
use this code and put your navigation bar in the XIB of the view.
[navigationController setNavigationBarHidden:YES animated:YES];
Other wise your view will be come down by 44 points the height of the navigation bar.

Resources