xamarin iOS app stays in background after PresentViewController dismissed - ios

I have a Xamarin Forms app. The iOS app presents a modal view controller like so:
UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(viewController, true, null);
The current view goes into the background and the modal view is presented. When that modal view is dismissed, it goes away but the view that went in the background stays there. I'm not sure how to bring it back to the front and make it active.
FYI, the viewController in this case is a native iOS UIViewController inside a framework. When used inside a native iOS project in Xcode, the modal view dismisses properly and the old view returns to the foreground.
Any thoughts?

Related

Forcing orientation on a full screen modal doesn't work on parent controller

iOS 16 introduced a new API for forcing orientation changes, which implies using the requestGeometryUpdate(_:errorHandler:).
It seems that it's not working as expected when using a full screen modal.
For example, let's say we have an app that locks the orientation in portrait mode except for a modally presented controller, a parent controller A and a modal controller B :
A is displayed
We put the device in landscape mode - A stays in portrait mode
B is opened modally fullscreen from A
B is displayed in landscape
B has a button to go back to portrait mode using the requestGeometryUpdate(_:errorHandler:)
B is dismissed through a button
A ends up in landscape
In the app delegate, we used supportedInterfaceOrientationsFor to force the app in portait mode except for the controller B.
We tried to call setNeedsUpdateOfSupportedInterfaceOrientations every time we call requestGeometryUpdate(_:errorHandler:).
We also tried to call it on the viewWillAppear from the controller A.
We finally tried to call requestGeometryUpdate(_:errorHandler:) from the controller A's viewWillAppear, without any luck as well.
Is this a bug in iOS 16 or are we missing something ?
It seems to be working as expected when displaying the modal over the current context, but it's not what we want in this case.
I can provide an example project if needed.

Tapping preview in context menu on iPad doesn't animate presentation of full screen view controller

I have a context menu in my app that shows a photo preview above the actions, and tapping the preview presents that view controller full-screen. On iPhone, when you tap the preview there’s a lovely animation - it bounces into full screen. But on iPad, when you tap the preview the context menu dismisses and then the screen appears without any animation.
This is the (new*) default behavior on iPad. The idea being you can use your own presentation animation. To get the system "pop" style that's default on iPhone, set the preferredCommitStyle to .pop on the UIContextMenuInteractionCommitAnimating object.
*I think it changed in iOS 13.4. This change broke the Photos app as well. 😅

How to prevent iOS 13 behaviour for appodeal fullscreen video ad?

In iOS there is a new behaviour for modal view controller when being presented. Now it's not fullscreen by default and when I try to slide down, the app just dismiss the View Controller automatically.
How can I prevent this behaviour and get back to the old good fullscreen modal vc? I face this problem while using appodeal framework.
Code to show videoad
if Appodeal.isReadyForShow(with: .nonSkippableVideo){
Appodeal.showAd(.nonSkippableVideo, rootViewController: self)
}

pushViewController doesn't work when app is in background?

I recently refactored an app to use a UINavigationController and pushViewController(...) to transition back and forth between the main UIViewControllers of my app. Previously I was using present(...) with no issues. The app is a music player and has the appropriate background mode.
The transition to view controller B from view controller A happens after a 5 second countdown and thus can happen in the background if the user hits their home button or turns the screen off.
The issue is that the push, and all relevant events that are supposed to kick off when the view did appear, do not fire while the app is in the background, and immediately fire as soon as I turn the display back on or bring the app into the foreground.
Is there any way to force the push to happen even if the app isn't visible, or a different method to push and display the view controller?
Thank for any insight!
let nav = self.parent as! UINavigationController
print("Attempting to .pushViewController...")
nav.pushViewController(sessionVC, animated: false)
print("After .pushViewController...")

How to make UIPopoverController visible at startup in portrait orientation?

I'm making an iPad application using a UISplitViewController. I want the masterView visible in a UIPopoverController when the app starts (and only when it starts) in portrait mode. If I use the presentPopoverFromBarButtonItem:permittedArrowDirections:animated: method in the splitViewController:willHideViewController:withBarButtonItem:forPopoverController:
delegate function, I get the following error, when I start the app in portait mode:
Popovers cannot be presented from a view which does not have a window.
Can anybody help me?
The particular error says that you must add the view to a window before showing the popover, not the other way round. Try sending presentPopover… from the application delegate's -application:didFinishLaunchingWithOptions: after adding the view to your app's window.

Resources