Sebastian Flückiger Sebastian Flückiger - 3 years ago 352
iOS Question

iOS 11: self.performSegue() not working

i started the migration to Xcode 9 & iOS 11 build today.

in my storybased app, the following code:

self.performSegue(withIdentifier: Const.UI.Segue.showIntro, sender: self)

runs fine in all previous iOS (just verified with iOS 10.3, 10.0, 9.0) but does not run in iOS 11.

additional code:

private func handleSuccessfulLogin() {"Logged In")
self.performSegue(withIdentifier: Const.UI.Segue.showIntro, sender: self)

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
print("starting segue " + segue.identifier!)

override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
print("should perform segue")
return true

printout (iOS 11):

> Logged In
> starting segue showIntroSegue

Expected result: new controller pushed

Actual result iOS 11: nothing at all happens

Any ideas what the reason might be?

The function
is called after a successful login with
AWSCognito / AWSFacebookSignInProvider
, a facebook login. On iOS there is a new popup
continue with facebook
which i suspect to be the reason, but no way to verify it.. On the 2nd call this popup does not appear (as facebook already is authorized), and then the segue triggers correctly.

Note, i also tried this snippet, same result.

OperationQueue.main.addOperation {
[weak self] in
self?.performSegue(withIdentifier: Const.UI.Segue.showIntro, sender: self)

Answer Source

I found the solution to be at a completely different place (as so often). The reason was that I had a logic in place in applicationDidBecomeActive that was replacing the current storyboard (bad approach!) - the additional popup from the FB Kit led to a recreation of my container view controller. Thus i had self.navigationController == nil during the call to perform the segue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download