UIViewController child view controller accessibility - ios

While adding a child view controller, is there a way to hide parent VC elements from the voiceover access?
I've a parent view controller P, which adds a child view controller C as a full screen page view controller. Once the transition to the full screen finishes, the voiceover still goes through the elements in the parent view controller.
Any idea how I can hide/disable accessibility of elements in the parent view controller?

You can set accessibilityViewIsModal on the occluding view. Note that the view is made modal relative to sibling views, not globally. If you need to hide views in parallel view hierarchies from the accessibility hierarchy, consider toggling accessibilityElementsHidden.

Related

NavigationController with sticky view at top

I have a navigation controller with its root view controller, I need to add a fixed/ sticky view at the top of the root view controller, so that only the content below it navigates whenever I use pushViewController or popViewController, is that possible?
Look at the image below, I want the red area to be fixed/sticky a.k.a doesn't navigate or move when I push or pop, only the blue area to navigate
P.S: The containerView won't work here as it acts as normal view, and adds its sub view controller's view to it.
Add a container View to add as child view controller for your navigation and set navigationBar as hidden. Now you can add the above view with 44 height as a sticky one for all View controllers.
If you want a way to communicate between child view controllers under navagtion with the parent I would suggest NSNotification observer or a Delegation to be confirmed by all child VC or by a subclass of UINavigationController.
This is a sytematic way.
Other dummy way is to add a view to the window and set the view.layer.zPosition if you want it below or above any other view.
you can use Container View and show/hide other views

How to override interactivePopGestureRecognizer?

I have view controller containment logic in one of my screens: a container view controller is pushed on navigation controller with initial child view controller (company list) and its view. If user taps on some row then another child view controller (company details) is added and its view is show. There are more child view controller that are shown as user goes deeper.
Those child view controllers and views are added and opened with normal fromRightToLeft view transition. The problem is when user swipes back to previous page then interactivePopGestureRecognizer pops the whole container view controller regardless of its internal child view controllers.
How to have interactivePopGestureRecognizer enabled but get a callback on container view controller and conditionally allow or deny (and perform my custom transition animation for the views of child view controllers)? Or the only way is disable it and implement pan/swipe gestures completely on my own...

What is the correct way to handle multiple view controllers on the same screen?

I'm having a view controller, that has few controls and images, and is located on top of the screen. I will have a space below it for child view controllers and their views.
I will show one child view controller at a time, what is a good way to do that?
Total amount of child view controllers is around 6, they are very different, so reusing some container view controller won't really work.
When pressing some button on these controllers I will move to next one.
Should I make some property, let's say contentView that will hold a view of the controller that is currently on screen?
How do I handle rotation if I don't use auto layout?
EDIT: This is more a theory question, I know of methods addChildViewController and know the way how I add views and controllers to their parents. I just want to know the good way to do that.
It depends somewhat on how you want to transition between the different child view controllers, but your question already lists a good approach.
You definitely want a different view controller for each of the children. Add a container view to your top level view. This view is where rotation and auto-resizing are handled. The contents of this view could be the child view controllers views themselves (and you control the transitions using one of the methods like transitionFromView:toView:duration:options:completion:) or the container view could hold a UINavigationController and you just push the child view controllers into it.
Whatever the container view holds, you need to take care if any of your child view controllers tries to present another view controller as a modal. The presented view controller needs to be presented by the view controller at the top of the hierarchy or the presented view may no interact correctly or truly be presented in front of other screen elements.

Segue from a scrollview

I have a UIscrollview that takes up about half of a screen. The scrollview contains a series of view controllers that have buttons that have segues to another view controller. When that segue is followed, it loads the view controller on top of the current scrollview.
I want that new view controller to act like any other modal segue would act if the button was not within a subview or scrollview. In other words, take up the whole screen.
Can you use segues from within a subview or a scrollview?
Thanks!
The scrollview contains a series of view controllers that have buttons
that have segues to another view controller.
An instance of UIScrollView can't "contain" view controllers -- it can only contain other views. It might contain views that are managed by other view controllers, but if you're using many view controllers all at the same time you may want to read Am I abusing UIViewController Subclassing?.
I ended up just using delegates and protocols between the views in the scrollview and the parent view controller and then I launch the new view from the parent view controller. Seems to be doing the trick.

UIViewController as a subview for other view controllers

My app has a menu button which is available in every view controller. Every time a user taps on the menu button, a small menu pops up. The menu has multiple UIButtons, and each button links to another view controller.
My current solution is to create a view controller with a nib for the menu view and add it as a subview to each of the other main view controllers.
Is there is a better solution?
There could be multiple ways of doing it and I don't think there is the best answer.
However, in the performance perspective, implementing a view container such as UINavigationController or UITabBarController would be most effective.
Implement a root view controller (whose view is added as the only direct subview of the application window), and add the menu as a subview of its view. Let the root view controller decide (or know) which view to display, and add the view as a subview of its view, below the menu.
In this way, the view for the menu need not be removed and added again to the current view hierarchy.

Resources