1
我已經創建了一個應用程序,在初始VC上有4個UIButtons。每個按鈕都會跳到另一個VC(所有情況下都相同),但參數不同。三維觸摸快速行動電話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調用操作方法。 –