Controlling View and NavigationBar of an App opened programmatically with open(_:options:completionHandler:) - uinavigationbar

When I open a target iOS App programmatically from my App, the target App opens fine and works as expected. The target app opens as a Modal.automatic view. Here is the problem: the remaining visible sliver of the original App & Nav Bar is very dark, and the Nav button at the TopLeft of the screen window is Black and extremely hard to see. I know it is there but my users will be lost and unable to return to my App.
I can not find an approach to either move the target's modal window down a few pixels or otherwise make the Nav bar and its button (return to calling App) more prominent. I have tried altering the NavBar Appearance (Opaque, back = white, text=black), but my chosen colors persist on up to the first time the target is opened, after that the Nav Bar is dark translucent again.
Of note, the calling App's UIView has a view.background color which is a bright yellow pattern image. The call to the target App is routine:
let appURLScheme = "xyzzy://"
guard let appURL = URL(string: appURLScheme) else { return }
if UIApplication.shared.canOpenURL(appURL) {
UIApplication.shared.open(appURL,
options: [:],
completionHandler: nil )
}

Related

MFMailComposeViewController behaves differently in iOS 13 simulator and device

I'm trying to display MFMailComposeViewController in an app.
if MFMailComposeViewController.canSendMail() {
let mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.navigationBar.tintColor = .white
mailComposeViewController.mailComposeDelegate = self
mailComposeViewController.setToRecipients(["support#gmail.com"])
mailComposeViewController.setSubject("Feedback")
present(mailComposeViewController, animated: true)
} else {
print("This device is not configured to send email. Please set up an email account.")
}
In iOS 12, it shows up without an issue. In both simulator and device.
But when I run the same project on a device running iOS 13, it looks like this.
The navigation bar color is gone. Also the send button is also invisible.
So I added mailComposeViewController.navigationBar.backgroundColor = .mv_primary but it still doesn't show on the device. Strangely the background color shows in the simulator.
However there's a strange behavior. The MFMailComposeViewController immediately dismisses by itself when I run it in the simulator.
The following error also shows up in the Xcode console.
[Common] [FBSSystemService][0x5f27] Error handling open request for
com.apple.MailCompositionService: {
userInfo = {
FBSOpenApplicationRequestID = 0x5f27;
}
underlyingError = ; } 2019-11-01
14:40:05.214158+0530 MailCompose[11289:262267] [Assert] Connection
request invalidated without resuming our _serviceSessionConnection.
This is an error. 2019-11-01 14:40:05.216901+0530
MailCompose[11289:262054] [General] #CompositionServices
_serviceViewControllerReady: NSError Domain=_UIViewServiceInterfaceErrorDomain Code=0
I guess the weird dismiss error is a Xcode bug. But how do I fix the background color and the send button not showing up in the device?
This is how I set all the navigationbar related styles.
UINavigationBar.appearance().barTintColor = .mv_primary
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
if #available(iOS 11.0, *) {
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
}
Demo project
Add this line of code before present it. It will work normal. This a change in iOS 13
mailController.modalPresentationStyle = .fullScreen
The reason why the Mail composer dismisses immediately is because you can't actually send an email from the simulator. The implementation is different from iOS itself.
What I guess is happening here is that while the simulator implementation uses just some normal UI elements, the MFMailComposeViewController on native iOS is actually hosted like UIDocumentPickerViewController or UIActivityViewController. This means screenshots and trying to traverse the view tree is impossible, because the view is not an actual part of your application. They do that because these controllers contain user private information. Hosted view controller do NOT allow for customization, and do not comply with your global UINavigationBar.appearance(). This would explain why it does show up in the simulator and not on your native device.
This is new UI Style from iOS 13. You can disable it in Storyboard or set manual.
Presenting modal in iOS 13 fullscreen

UITabBarController opens and turns into black Screen in iOS13

I have a application flow
first presentviewController -> pushViewController -> PushViewController -> click button action Showing TabBarContorller which in .present(manner)
DispatchQueue.main.async {
let tabBarController = TabBarController.instantiate()
tabBarController.modalPresentationStyle = .overFullScreen
self.present(tabBarController, animated: true)
}
Application works fine in iOS 11. When running on iOS 13 its show black Screen
Well I guess if you present of push and then present I guess this make no difference with the application.
Your Inputs are highlight appreciated
Thanks in advance.

Pop up at bottom of screen when double tap home button. iOS, Swift

I have never seen this before and wondered how it would be possible to recreate. I have an app I am working on that uses maps.
This is from Shpok.
It shows a pop up at the bottom of the screen when double pressing the home button.
The app is simply creating an NSUserActivity and setting the mapItem property.
Something like:
let activity = NSUserActivity(activityType: "my.domain.activity.name")
activity.title = "Some Title"
activity.mapItem = anInstanceOfMKMapItem
activity.becomeCurrent()

How should we put custom UIButton in google maps app?

By clicking on a button am navigating to google maps app, and there am showing directions from one location to another location.
here is the code which i wrote in button
#IBAction func movetonextclass() {
if UIApplication.shared.canOpenURL(URL(string: "comgooglemaps://")!) {
let googleMapUrlString: String = "comgooglemaps://?saddr=&daddr=\(CDouble(startLat)),\(CDouble(startLong))&mode=driving"
UIApplication.shared.openURL(URL(string: googleMapUrlString)!)
}
else {
let googleMapUrlString: String = "http://maps.google.com/maps?f=d,&daddr=\(CDouble(stopLat)),\(CDouble(stopLong))"
UIApplication.shared.openURL(URL(string: googleMapUrlString)!)
}
}
now i would like to display a custom UIButton in that screen.
if i click on that button, i should navigate to my own app
how should i put a button in google maps screen?
could any one help me with this
You cannot add anything in not your application, but actually from ios 9, when you open an another app when your app in active state you can back to previous application by tapping at the top left corner.

Swift: Animating a view (for in-app notifications) onto the screen for a few seconds before removing

I am attempting to do what is described perfectly here: https://github.com/bryx-inc/BRYXBanner
I want to create a banner that pops down on the screen for a few seconds before being removed (or removed when it is tapped on). The above project is great up until iOS 9. After that and with iOS 10, the banner no longer works as predicted and either shows itself without an animation for a third of a second or it doesn't show.
How can I add a view that animates onto the screen and then back off to provide a user a quick "No Internet" notification in-app. I want to avoid using the notification center.
I had a similar problem and created my own library for it: MDNotificationView
The example app on GitHub implements your idea. Here is a small snippet implementing it:
let view = MDNotificationCompactLayoutView()
view.textLabel.text = "No internet connection."
let notificationView = MDNotificationView(view: view)
notificationView.delegate = self
notificationView.show()
// MARK: - Notification View Delegate
func notificationDidShow(notificationView: MDNotificationView) {
// Hide the notification view automatically after 5 seconds.
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
notificationView.hide()
}
}

Resources