Swipe to different View Controller in UIPageViewController when modal is presented - ios

I have several UIViewControllers within a UIPageViewController. I can then swipe between these view controllers and everything works fine. However, most of these view controllers present a modal view controller using presentViewController:. When there is a view controller on screen that was presented in this way, I can no longer swipe between the other view controllers in the UIPageViewController.
For example, if one of the view controllers is eMail and another is Address Book, the eMail may do a presentViewController: to write a new eMail. The user would like to swipe to the address book view controller to look up an email address. The swipe gesture is currently disabled because of this modal view. Is there a way to enable swiping between the VC's of my page view controller when one of them is presenting a modal view?

I would suggest you to not present it at all.
Just add a view controller as a child view controller, also add its view as subview of current:
[self addChildViewController:composeMailController];
self.view addSubivew:composeMailController.view;
Adding it as a child will pass some events (like rotation) from parent to child.
Ofcouse you will have to animate appearance of the child view if this approach will work for you at all.

Related

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...

Showing a UISplitViewController inside a pop over

I'm wanting to create a UI where I have a popover that comes from a button that and contains a split view UI with two table view controllers side by side.
The storyboard I have now has a normal page with a button, the button has a popover segue to a split view controller.
The split view controller has a master relationship to a navigation controller which has a root view controller of a table view controller.
The split view controller has a detail view controller to another navigation controller which again has a root view controller of a table view controller.
When I launch the pop up it only ever displays the master controller, not the two side by side.
UISplitViewCpntroller can only be the root view of an app - as such, you cannot put them in a UIPopover or any other non-root view.
You would have to create your own UISplitViewCpntroller type view (or look for some open source code).

How to dismiss a NavigationController in Storyboard?

I've looked everywhere for this, so as a last resort I figured I should ask the question.
I'm using Storyboard in XCode and have a navigation controller as my initial view. The root view of this navigation controller is a table view. In this table view, I have a button in the navigation bar that flips the view horizontally via a modal segue to a navigation controller. The root view of this controller is my map view. Now, when I want to dismiss this map view using [self dismissViewControllerAnimated:YES completion:nil] it doesn't work. It does if I take out the navigation controller. So, I'm guessing the dismissViewController is getting passed to the navigation controller, and not doing anything. I know I could implement a class for the navigation controller to handle the call and pass it on, but I don't want to do that unless absolutely necessary.
So to solve this question:
I need a way to switch between table view to map view using the flip horizontally animation and vice versa.
I need to have a navigation controller in both views, I could either be the same one, or a different one. I can't seem to find a way to use the same one, since any transitions would be pushes which don't do the flip horizontally transition.
Thanks in advance for the help!
Who is self when you call [self dismissViewControllerAnimated:YES completion:nil]?
The receiver of this message needs to be the view controller which presented the modal view controller you want to dismiss. If you call it on the presented view controller, or (in the case of container view controllers like UINavigationController, one of the view controllers it manages), UIKit will try to do the right thing but won't always succeed.
Presuming the self you refer to is the view controller containing the map view, you can get the presentingViewController property to get the object you should call dismissViewControllerAnimated:completion: on. (And if you need to get the navigation controller that's in between, use the navigationController property.)

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