0

K...I'm totally new (basically reading Apple's developer documentation). (Sorry if I double-posted, but I couldn't find an answer)

I have a simple app (paid to develop from FreeLancer) with 2 ViewControllers. The first has 2 buttons that when tapped will take you to a particular textbox (for entry) in the 2nd ViewController.

(After some research) I was able to add 2 static QuickActions. I want the cursor/focus to go to the respective textbox based on the selected QuickAction. I am able to get a dialog box to open after the quickaction is taken but thats it.

Ex: 3d Touch and tap the "Go to Name" quick action, will take me to the txtFirstName in the 2nd ViewController.

Code from ViewController2nd (after tapping the respective button in the 1stViewController):

class ViewController2nd: UIViewController, UITextFieldDelegate, 
    CLLocationManagerDelegate {

@IBOutlet weak var txtFirstName: UITextField!
@IBOutlet weak var txtSecondName: UITextField!


var nTouched : Int = 0


override func viewDidLoad()
{
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    txtFirstName.delegate = self
    txtSecondName.delegate = self

    if(nTouched == 1)
    {
        txtFirstName.becomeFirstResponder()
    }
    else if(nTouched == 2)
    {
        txtSecondName.becomeFirstResponder()
    }

Code in AppDelegate for QuickAction (which works):

QuickActions UIApplicationShortcutItemType are "AddFirst" and "AddSecond".

//called when QA tapped  
func notifyUser(message: String) {

    let alertController = UIAlertController(title: "Quick Action
    Triggered",
                                            message: message,
                                            preferredStyle: .Alert)
    let okAction = UIAlertAction(title: "OK",
                                 style: .Default,
                                 handler: nil)

    alertController.addAction(okAction)


window!.rootViewController?.presentViewController(alertController,
                                                      animated: true, completion: nil)
}

//end



 func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {


    switch (shortcutItem.type) {

    case “AddFirst” :


     //will comment out after it's working   
       notifyUser(shortcutItem.localizedTitle)

    case “AddSecond“ :

       //will comment out after it's working   
        notifyUser(shortcutItem.localizedTitle)


    default:

        break

    }

    completionHandler(true)

}

So I guess the question is what code to i need to put in the Case statements to take me to the right textbox in the 2ndviewcontroller?

Thank you all in advance!

Zero Kool
  • 1
  • 1

0 Answers0