I am presenting a view controller modally in iOS app. The issue is that there is no crash and the app freezes as soon as presentViewController:animated is called. The stats
Ok, this is bizarre, but I hope it helps: I have the EXACT same issue, the CPU jumps to 100% and view never shows. Works perfectly well in Xcode 6.4. In Xcode 7.1, on the view that I am calling, I have got a UITextView with some placeholder text "Notes:". What I found is that if I clear out the placeholder text, the view LOADS and all of the procedures execute as normal. If the placeholder text length is greater than 9 characters, the view also loads and procedures execute as normal. If the placeholder text length >0 and < 10, it's a no go. No view and CPU at 100%. This is odd, I realize, but hopefully it helps you out. Like you, I've got no errors or console output to show, it just spins.
EDIT FYI, blanking out the placeholder text in the storyboard, and just setting it in code fixes this as well irrespective of length
I had the same exact problem as described in the OP and the answers:
PageViewController
)I ultimately tracked this down to my "Note" view being set as the First Responder, When my view appears, via override func viewWillAppear(_ animated: Bool)
, I set the note UITextView
to become the first responder, noteTextView.becomeFirstResponder()
.
If I removed that line and never tapped the note field, my app would successfully resume from the background.
To fix this problem, I ended up adding observers for when the app moves to the background and moves into the foreground. In these observers, I make the note text view become and resign firstResponder, respectively.
override func viewDidLoad() {
super.viewDidLoad()
//set up your view controller here.
NotificationCenter.default.addObserver(self, selector: #selector(self.appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.appMovedToBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
}
@objc func appMovedToForeground() {
self.noteTextView.becomeFirstResponder()
}
@objc func appMovedToBackground() {
self.noteTextView.resignFirstResponder()
}
I'm not sure if I should be doing something differently to prevent this problem, or if it's best practice to resign first responder when the app goes into the background, but this seems to work for me.
Same issue here.
I have a UITextView with the default string " Text " and fails with 100% CPU load. I was putting the placeholder only in code but until I remove the " Text " from the storyboard didn't work.
My code was developed in Xcode 6 and I noticed this error after send a new app revision builded with xcode 7.