1
私は最初のVCに4つのUIButtonsを持つアプリケーションを作成しました。 各ボタンは別のVCとセグメンテーションします(すべてのケースで同じですが、パラメータは異なります)。3DタッチクイックアクションコールUIButton
@IBAction func googleBtnPressed(_ sender: AnyObject) {
searchEngine = "Google"
print(searchEngine)
performSegue(withIdentifier: "google", sender: nil)
}
@IBAction func bingBtnPressed(_ sender: AnyObject) {
searchEngine = "Bing"
print(searchEngine)
performSegue(withIdentifier: "google", sender: nil)
}
@IBAction func ddgBtnPressed(_ sender: AnyObject) {
searchEngine = "DuckDuckGo"
print(searchEngine)
performSegue(withIdentifier: "google", sender: nil)
}
@IBAction func customBtnPressed(_ sender: AnyObject) {
performSegue(withIdentifier: "custom", sender: nil)
}
if let vc = segue.destination as? ViewController {
if searchEngine == "Google" {
vc.url = NSURL(string: "https://www.google.com")
vc.segueUsed = "google"
vc.searchEngine = "google"
}
else if searchEngine == "Bing" {
vc.url = NSURL(string: "https://www.bing.com")
vc.segueUsed = "google"
vc.searchEngine = "bing"
}
else if searchEngine == "DuckDuckGo" {
vc.url = NSURL(string: "https://www.duckduckgo.com")
vc.segueUsed = "google"
vc.searchEngine = "duckduckgo"
}
}
}else if segue.identifier == "custom"{
print(segue.identifier!)
if let vc = segue.destination as? ViewController {
vc.segueUsed = "custom"
}
}
私は、3Dタッチのクイックアクションを使用して、ホーム画面から、これらの4つのボタンを呼び出したいです。 私はすでにのInfo.plistファイル内のエントリを作成しましたが、どのように私はこれを実装するのですAppDelegate.swift
<key>UIApplicationShortcutItems</key>
<array>
<dict>
<key>UIApplicationShortcutItemType</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).Google</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Google</string>
<key>UIApplicationShortcutItemIconType</key>
<string>google</string>
</dict>
</array>
で応答を処理しながら、苦労していますか?
ありがとうございました。
appDelegateからアクションメソッドを呼び出す方法について詳しく説明できますか。 –