UIViewController transition from left to right beneath another UIViewControler - ios

I have a container UIViewController with a child that acts as a menu. This loads the other child UIViewController. I would like the other UIViewControllers to animate in and out behind the menu which is semi-transparent. I have only been able to make it work when the other children are above the menu (shorter than the entire screen so menu has room on the bottom) but have not achieved a sliding effect behind the menu. Is this effect possible?

Assuming you are adding menuController view and new viewController view's as subViews to containerViewController view.
First add that new viewcontroller view as child to containerView's view.
Now that view will be on top of menu's view.
Now bring the menu view to top by
[containerView bringSubViewToFront:menuView];
Above instruction makes menu view to be on top of sliding viewController's view.Now do the sliding animation on new viewController's view.

Related

Is it *possible* to make your own Tab Bar Controller?

I have a project where our tab bar has a big middle button (that extends above the tab bar) and other custom behaviors including a badge icon and colored labels.
I got "smart" and decided to just write my own tab bar and tab bar controller to go with it. The problem I've run into is that when one of the tabs is wrapped in a UINavigationController, that view always takes up the whole screen (you can't capture a UINavigationController into a small subview) and so I have to manually inset the content on those views.
Is there a smart way to handle this? It feels gross to just cut the content short on each screen by 100 points...that doesn't feel right at all.
What approach should I take...or should I just automate the content insets programmatically?
A tab bar controller is just a scroll view with a view at the bottom that toggles between the scroll view's offset. I assume you want the tab bar controller to be at the root of your app, so in the root view controller, add a UIScrollView.
Then add the views of the view controllers (the tabs) to that scroll view, and anchor them appropriately so that the scroll view scrolls. Make the heights and widths of these view controllers full screen. Before you add them to the scroll view, you must create a parent-child relationship between the root view controller and its tabs.
self.addChildViewController(tabOneViewController)
tabOneViewController.view.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(tabOneViewController.view)
tabOneViewController.didMove(toParentViewController: self)
tabOneViewController.delegate = self // so that your tabs can communicate back to the controller
// add constraints
Each of these view controllers will ideally be or contain the navigation controller for that section.
Then just add the tab bar to the view of the view controller, not to the scroll view (add this after the scroll view so that it sits above the scroll view). This tab bar is just a regular UIView, most often anchored to the view controller's bottom safe area. Because its a part of the view controller's view, and not the scroll view, it has no impact on the content behind it.
The benefit of a custom tab bar setup like this is that you can navigate between tabs on tap or by pan gesture. To navigate between tabs by tapping on the buttons in the tab bar, simply change the scroll view's content offset:
// this would move to the third tab
scrollView.contentOffset = CGPoint(x: view.bounds.width * 2, y: 0)
Add your bells and whistles and you're set.

Make UIPageViewController not be covered by a toolbar

I have a UIPageViewController that is in a container view which contains a UIToolbar on the bottom.
Currently the toolbar covers all views that are at the bottom of the view controller that the UIPageViewController is showing.
I can inset the frame of the UIPageViewController but then you can't see the blurred child view under the toolbar. Is there a way to inset the view so it will make the child constraints relative to the top of toolbar, but still be able to see the view underneath the toolbar?

TabBar in TableViewController is not at the bottom

I am trying to add a tabBar to my TableViewController but it is not a the bottom it just act like a cell
Here is a screenShot:
When using a UITableviewController storyboard scene, every Tab Bar or Toolbar you drag in it is automatically put into the tableView tableFooterView.
If you don't want that, you have to create an UIViewController scene. You will therefore be able to drag your Tab Bar or Toolbar in it, set its auto layout constraints and then add your UITableView in the UIViewController scene (see image below).
However, there is another solution. Select your Navigation Controller scene and go to the Attributes Inspector. In the Simulated Metrics, go to Bottom Bar and select "Translucent Tab Bar" or "Translucent toolbar". Then, select your UITableviewController scene and repeat the previous operation (see the picture below).
If you do so, all controllers following your Navigation Controller will have a Tab Bar or Toolbar (that's another problem that can also be fixed).
Use autoLayout to pin it to the bottom

UISplitviewController with sliding menu

My split view controller is set as the root view controller in my app delegate.
I need to slide my split view to the right (master and detail view) about 200px, while sliding in a menu view from left to right (left of the split view) at the same time which has a width of 200px. So my split view would slide off the main view while the menu view appears. Ive tried adding a subview to UIWindow which I beleive is not the right way to do it. Ive tried adding my menuViewController to my split view controllers' master view controller. But it doesnt seem to work. Help please!!!

How to add a segmented control anchored to the bottom of the screen below a table view in interface builder

I have a view controller (derived from UIViewController not UITableViewController) containing a table view. The controller and view are both within the same xib.
I want to add a segmented control to appear at the bottom of the screen, with the table view taking up the rest of the space above it.
However in IB it will not let me place the segmented control as a direct child of the view controller, it will only let me place it as a child of the table view i.e. the hierarchy looks like this:
Navigation Controller
Navigation Bar
Main View Controller - Item
Table View
Segmented Control - First, Second
Navigation Item - Item
Bar Button Item - Style
If I run it like this then the segmented control floats up and down depending upon how many items there are in the table view.
What can I do to get it to be locked to the bottom of the screen?
UPDATE:
I got nearer - I added a view as a child of the main view controller and made the table view and segment control children of that, but now only the top half of the control appears when I run the simulator but everything looks fine in IB, why is there a discrepency?
Side question - as a starting point I'm using one of Apple's sample project, why was there no main view? When should you and when should you not have a main view?
Thanks
Just open your xib and expand your view and drag Tableview control under View and also drag segmented control under view not in tablview this will work.
you need to set frame of both in you viewDidLoad
tblview.frame = CGRectMake(0, 0, 320, 400);
sgmntcontrol.frame = CGRectMake(50, 405,150 ,50)];

Resources