0

K...私はまったく新しいものです (基本的に Apple の開発者向けドキュメントを読んでいます)。(二重投稿で申し訳ありませんが、答えが見つかりませんでした)

私は、2 つの ViewControllers を備えた単純なアプリ (FreeLancer から開発するために有料) を持っています。最初のボタンには 2 つのボタンがあり、タップすると 2 番目の ViewController の特定のテキスト ボックス (入力用) に移動します。

(いくつかの調査の後) 2 つの静的 QuickActions を追加することができました。選択した QuickAction に基づいて、カーソル/フォーカスをそれぞれのテキスト ボックスに移動します。クイックアクションが実行された後にダイアログボックスを開くことはできますが、それだけです。

例: 3d タッチして [名前に移動] クイック アクションをタップすると、2 番目の ViewController の txtFirstName に移動します。

ViewController2nd のコード (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()
    }

QuickAction の AppDelegate のコード (動作します):

QuickActions UIApplicationShortcutItemType は「AddFirst」と「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)

}

したがって、問題は、2ndviewcontroller の正しいテキスト ボックスに移動するために、Case ステートメントにどのコードを入力する必要があるかということだと思います。

よろしくお願いします!

4

0 に答える 0