TwitterKit dismisses my viewcontroller after cancelling to log in


#1

I am using Twitter.sharedInstance.logInWithCompletion to log in.
My view controller is dismissed unexpectedly, when I press cancel button at the timing of screenshot attached.

This occurs in TwitterKit iOS(1.12.0).


TwitterKit is dismissing callee controller in airplane mode
TwitterKit is dismissing callee controller in airplane mode
#2

Thanks for posting this, can you include some sample code around when this is happening?

Thanks,
Mike


#3

Here is a sample code (Swift 2.0):

import UIKit
import Fabric
import TwitterKit

class TestViewController1: UIViewController {
    init() {
        super.init(nibName: nil, bundle: nil)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var firstTime = true
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        if firstTime {
            firstTime = false
            presentViewController(TestViewController2(), animated: true){}
        }
    }
}

class TestViewController2: UIViewController {
    init() {
        super.init(nibName: nil, bundle: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.whiteColor()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    var firstTime = true
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        if firstTime {
            firstTime = false
            Twitter.sharedInstance().logInWithCompletion { _, _ in () }
        }
    }
}

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        let consumerKey = "xxxx"
        let consumerSecret = "xxxx"
        Twitter.sharedInstance().startWithConsumerKey(consumerKey, consumerSecret: consumerSecret)
        Fabric.with([Twitter.sharedInstance()])
        self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
        self.window?.rootViewController = TestViewController1()
        self.window?.makeKeyAndVisible()
        return true
    }
}

In this case, TestViewController2 will be dismissed unexpectedly.

Thanks,


#4

Thanks @y_mazun, I’m looking into this.


#5

Was this issue fixed?
I have same problem.


#6