我正在努力制作一个应用程序,允许某人在搜索栏中输入文本,并且该应用程序将自动打开“https://www.example.com/(来自搜索栏的文本)。”从类'UIViewController'和'UISearchBar'的多继承
我不断收到构建失败和有关从类UIViewController
和UISearchBar
多重继承的错误
任何帮助,将不胜感激下面
代码:。
import UIKit
class ViewController: UIViewController, UISearchBar {
override func viewDidLoad() {
super.viewDidLoad()
func searchBarSearchButtonClicked(_ searchBar: UISearchBar)
{
searchBar.resignFirstResponder()
if let url = URL ("https://www.doughnationgifts.com/",doughnationcode)
let doughnationcode = String(searchBar.text!)
if #available(iOS 10.0, *)
{
UIApplication.shared.open(URL, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(URL)
}
}
}
}
为什么你想延长'UISearchBar'?为什么'viewDidLoad'方法中的searchBarSearchButtonClicked方法? – rmaddy
我应该使用另一种方法吗?谢谢。 – Daagoodr