POSSIBLE LEAD ON WHAT'S CAUSING THE ISSUE/POSSIBLE SOLUTION TO LOOK INTO
this has happened me just now too. There was no such error until the last ten minutes and I've been running the app all day with no queries that would cause this.
The errors give no indication of what's wrong, but when I removed the last thing I added before the issues arose it resolved. I had created a String extension as per below and then tried to use it. When I removed the extension the issues disappeared again.
Probably not the exact same thing for everyone, but if you have a similar extension changing an Apple type then it looks like certain methods that take time to go do something shouldn't be used because it would delay the main thread - in my case i was trying to check if a string could be opened as a url. I'm guessing here and don't fully understand but least the issues seem to disappear. Wish there was more info in the warning itself to help us identify why!
//MARK: - Extension to check if string is a valid url
extension String {
var isValidURL: Bool {
if let url = NSURL(string: self) {
return UIApplication.shared.canOpenURL(url as URL)
}
else if self.contains("https") == false && self.contains("www.") == true { //in case user didn't put https, check if added that
let newstring = "https://\(self)"
if let url = NSURL(string: newstring) {
return UIApplication.shared.canOpenURL(url as URL)
}
else {
return false
}
}
else {
return false
}
}
}
Post
Replies
Boosts
Views
Activity
HOW I SOLVED FOR ME, hope this helps:
**Why it was happening: **
My app was going from a UIView that was inside a nav controller to a modal with no nav bar to a uiview again:
1.NAV BAR UIVIEW ---> 2. NO NAV BAR MODAL VIEW -> 3. UI VIEW
For some reason the final destination screen was treated like it was outside of the navigation controller group, because the previous screen was a modal that hid the nav bar. There are loads of overcomplicated-solutions out there about that part but I found the below combination fixed all issues. In brief, it's got to do with segues/presenting screen AND the "Presentation" setting in attributes in storyboard in the screen which followed the modal. HARD TO EXPLAIN BUT CHECK THE SOLUTION IN DIFFERENT COMBINATIONS TO SEE IF IT WORKS FOR YOU - Note my error message contained [Presentation] at the beginning which made me realise what might be happening, your error message may have something different but check for that word in the storyboard right hand pane.
**How I fixed it: **
If your app is using a navigation controller and you have a modal view (or any other view) that hides the nav bar:
A. Put this in your modal view :
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}
B. then put this in the view that comes directly after the modal view i.e. the one you present or segue to afterwards
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}
C. then, in storyboard, select the view that comes after the modal view and in the right hand pane, under attributes inspector --> view controller section: presentation -> select "Full Screen"