Cannot Get Unwind Segue Working with Modal View Controller Presented Over Current Context - uimodalpresentationstyle

This is regarding the latest version Xcode 6 and iOS 8.4.
I have a set of three view controllers, which VC2 & VC3 are presented modally:
VC1 -> VC2 -> VC3
Each of the segues are presented with a presentation style of .OverCurrentContext. I am using this presentation style because both VC2 & VC3 have a UIVisualEffectView with a blurred background to let the view underneath subtly show through.
My issue is that the unwind segue that I have created does not unwind neither VC2 or VC3 to VC1 with the presentation style of .OverCurrentContext. However, when I change the presentation style back to .Defatult it works.
I would really prefer to use .OverCurrentContext because having to use dismissViewController:animated:completion causes a second unwanted animation of both view controllers when dismissing. I want to be able to dismiss VC3 and immediately see VC1 without seeing VC2 animate it's dismissal between. Also, I do not like using presentingViewController.presentingViewController.dismissViewController:animated:completion because it also causes the unwanted animation of dismissing VC2 after VC3 has been dismissed.
Any suggestions on how to solve this?

I was able to use presentingViewController.presentingViewController.dismissViewController:animated:completion from VC3 to achieve the same effect as using an unwind segue.
However, as noted in my comment, I would still like to know why I had to resort to this rather than being able to use an unwind segue with .OverCurrentContext.

Related

How to unwind and jump directly to the destination View Controller

I have three View Controllers. VC1 is embedded in a UINavigationController and the other two are accessible via Push Segues, so they are on the Navigation Stack. I've created an Unwind Segue to jump back from VC3 to VC1. The issue is when the unwind segue is triggered, it pushes to VC2 and pushed to VC1. Although this happens quickly, I would prefer if it just went to VC1 directly. Is this possible?

Center popover on the previous view

I want to implement popovers in my app. When I change the storyboard segue option "kind" too "popover" I get an option to create a popover that has an anchor point with an arrow pointing to whatever I anchor the view/popover to. I don't want this. I want a popover that is centered on the previous view so you can still see parts of the previous view.
Picture of what i mean here:
I want the popover to behave like an independent view controller with buttons/labels etc. but obviously be smaller so you can see whats behind it. I also would like to know how to get the faded/darkened effect of the previous view after the popover shows.
You can Achieve this by using popover.swift third party library available in github.There is no issue from my end

Unwinding to viewController in different Navigation stack not working

As shown from the diagram, I am trying to have two viewControllers connected to the viewController on the right that serves as a menu between the viewControllers.
When the app is first run, it will load the first view controller on top. A button will show the menu modally and depending on which button is pressed (I am planning to add more) the corresponding viewController will be shown. The FIRST time that VC2 is pressed, it will load the second viewController, but when the menu is called again and VC2 is pressed, I want it to unwind instead of reload the view controller.
I have managed to unwind to the first viewController but when trying to unwind to the second viewController, the action is ignored. Your help will be greatly appreciated. Thank you.
You cannot unwind to a viewcontroller that has not been previously presented, because the desired destination VC will not be held in the navigation controller stack. Unwind segues are designed to 'pop' several steps back in a navigation history. In your scenario, the only possible pop available is to VC1.
You might also want to review your 'menu' concept, considering that UINavigationController objects can provide this behaviour with little fuss. You also don't need two separate UINavigationController objects to achieve what you want.
To do this, simply connect your menu VC as the root view controller for the UINavigationController, then connect the menu buttons to VC1 & VC2. Then you'll be able to move between the three screens with ease (see below for example).

UISwipeGestrureRecognizer not recogising swipe down - swift

All I have an UIImage in an UIView and I have added an UISwipeGestureRecogniser in both IB and in code. Code is like this :
EventImage.addGestureRecognizer(swipeRec)
EventImage.userInteractionEnabled = true
swipeRec.addTarget(self, action: "swipedView")
It will read a 'right' swipe fine, but I want to control a down swipe.
The UImage is in an View and the View is a part of a scrollview. So I have switched off DirectionLock and Bounces. So the UIView cannot be pushed down from the NAV BAR. And it still doesn't recognise a swipe down.
Any ideas ?
In IB I have created the recogniser by dragging an 'Swipe Gesture Recogniser' on to the image I want to be able to use the gesture.
Then if i select the 'Gesture in IB' I can set which way the gesture goes, and I select down like this :
Then I set an func in swift and it does not recogise down but when I change it to right i works fine.. I have checked the idea by using breakpoints and the breakpoint triggers on Right swipe (and left) but going down doesn't work.
I think it could be because I am in a scroll view.
I have added :
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
As I thought this may help.
Hope this is clearer.
A UISwipeGestureRecognizer can only recognise swipes in one direction.
That direction is set in the direction property of it.
If you want to swipe right or down then you will need two gesture recognisers. One for the right swipe and one for the down swipe.
recognizer.direction = UISwipeGestureRecognizerDirection.Down
Also, it help to read the documentation. All of this info is directly from there.

OS X gesture and the responder chain

I have a window with a content view that does several things, including managing an iOS like navigation controller.
The window's content view front most view is an invisible custom view set here to manage drag n drop all over the window, called DragNDropView.
Now I want to manage the swipe gesture to navigate (left swipe only) in the navigation controller.
Unfortunately the DragNDropView catches the gesture (if I implement -(void)swipeWithEvent: and set acceptTouchEvents:YES on it), and I don't want that since I want the views behind it to catch it, so of course I set acceptTouchEvents to NO on the DragNDropView.
I'm suprised the gesture event does not "go down" the view hierarchy as the views below do have their acceptTouchEvents set to YES when the front most view has acceptTouchEvents set to NO.
If the front most view does not handle the gesture, the gesture event is not passed to the views behind it????
gestures handling seems to be in NSResponder, so I even expect my NSViewController subclass to handle it, but it seems I can't.
Can any one help me understanding the problem?

Resources