Scenario: one UIViewController uses a custom transition to present another VC. This VC does not take up the entire screen; it's appearing as a layer on top of the first. Everything here is working great.
Now the presented VC wants to show a UIImagePickerController — to take a photo. But once that controller is dismissed, the second VC is displayed as a full-screen view: the effects of the original transition have been lost.
I've borrowed someone else's demo code for UIViewController transitions to quickly demonstrate this effect. Once you add the partial-screen second VC and bring up the camera view, dismissing it leaves you with a full-screen second view.
I've been unable to find other folks having this issue, but its repeatability suggests a framework bug.
https://github.com/aaronvegh/CustomViewControllerTransition
Found the solution: you have to set a modalPresentationStyle property on the camera VC before showing it. In my instance I set it to UIModalPresentationCustom, and that resolved the issue: when the camera is dismissed, the underlying custom transition bounds are retained.
Related
I have a strange animation when I pop a ViewController on my NavigationController. Short video to illustrate: https://youtu.be/IMbIS7evLrs
The view controller structure is:
UITabBarController -> UINavigationControllers -> UIViewControllers
I push the new VC using this line in my UIViewController:
[self.navigationController pushViewController:tripVC animated:YES];
Where tripVC is a newly created UIViewController.
Then the pop happens when the NavigationController Back button is clicked. I've also tried calling the pop programmatically using
[self.navigationController popViewControllerAnimated:YES];
from within tripVC and get the same strange animation.
What's particularly odd is I've used this structure / approach on other apps and haven't had this problem. Am wondering if there's some strange segue code in my app / am missing some animation code?
It seems that the background image in the second VC is wider than the device screen. As this scene pushes in/out the normally hidden edge of the image is revealed briefly.
Yes, for my case #Paulw11 is right. Enable clipsToBound to your root view.
If you haven't given background color of self.view then also it may occur.
This is the second reason for strange animation for navigation.
In an iPad master-detail application (the master is an UITableViewController and the detail a QLPreviewController) whenever I present a view controller modally and then dismiss it, the QLPreviewController stops receiving touch events or at least reacting to them. So, it's no longer possible to zoom in or out, or "bouncing" an image/document currently being shown, even after another image/document is selected and shown.
Keep in mind that before presenting the view controller modally everything works as expected and it's possible to zoom in/out.
Anyone knows a possible solution for this weird problem?
EDIT: added that this happens after dismissing the view controller presented modally.
EDIT 2: if the presentation style is UIModalPresentationFormSheet, the problem does not occur. It seems to only occur with UIModalPresentationFullScreen.
Although not a solution for this problem, a workaround is to present the view controller as UIModalPresentationFormSheet instead of fullscreen.
Yes that is expected behaviour.
When a ViewController is presented modally (I assume you are presenting something in a form sheet?), it prevents other view controllers receiving touch events.
The other alternative is to have a look at child view controllers as an alternative; but again, their touch events will take precedence over anything underneath.
I have three InterfaceControllers that I am presenting with the code:
self.presentControllerWithName("new", context: self)
For some reason, whereas the InterfaceControllers that are connected to the main Controller (with a segue) display the time in the upper right hand corner, the ones that are presented with the above code do not.
Is this because of the way I am presenting the Controllers, or is there another reason? If so, does anyone know a solution?
presentControllerWithName:context: will present your WKInterfaceController modally and as per Apple's documentation:
Discussion
After calling this method, WatchKit loads and initializes the new
interface controller and animates it into position on top of the
current interface controller. A modal interface slides up from the
bottom of the screen and completely cover the previous interface.
You might instead use pushControllerWithName:context: which will simply push your controller without covering the clock area
So in my code, I have a Tab Bar controller. When you click one of the tabs, it calls this code to open up a new storyboard (for video capture).
NavController *NC = [[NavController alloc] initWithCaptureInput];
[self presentViewController:NC animated:YES completion:nil];
In this view, he records a video and then the storyboard presents the segue. In that view, the user can preview his video. When he click's a button the storyboard pushes him to the next view.
In that last view, I use to call this in iOS 7 to make the app go back to the initial view (before the current storyboard).
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
This worked fine but in iOS 8, the top view is dismissed, and during the animation, you see the video preview view. Its only when the animation is done that the video preview view is removed (as it should be).
Can anyone tell me how I can have my proper animation where the top view is removed and during the animation you only see the initial view? This could be done if the app was to remove all the views at the same time (animating them at the same time too).
Yes, I've noticed that behavior, too. Unwind segues (as described in Technical Note TN2298) appear to handle this more gracefully.
In the view controller that you want to unwind to, add a method that looks like:
// use whatever name most descriptively captures the functional purpose of the
// view controller that you are unwinding _to_
- (IBAction)unwindToMainMenu:(UIStoryboardSegue*)sender
{
}
Then in the IB scene that you are transitioning from, you can control+drag from the "dismiss" button to the exit outlets control (as shown in that technical note or as shown here or here) and choose your unwind segue. In my casual experimentation, when you perform the unwind segue, it would appear that you do not see the interim views briefly during the transition.
I have a simple structure hooked up in Storyboard. I want to transition from one scene to another using a Modal transition. The scene where I am transitioning to is smaller then the current scene. So I want the "bounds" of the current scene to be visible behind the modal view.
But when I transition, and the transition is completed, the source view controller is removed from screen. Leaving black surroundings behind.
I have made a short video with the problem. Which can be found here. How can I make it so with the segue that the source view controller stays on screen?
Well, found the solution. In those duplicates people state it cannot be done except when you use a screenshot as "background".
But setting this:
source.modalPresentationStyle = UIModalPresentationCurrentContext;
on the source controller seems to work. Then it does not disappear.