Post not yet marked as solved
Post marked as unsolved with 0 replies, 282 views
Hi am looking for help, I have completed my xcode project following different course online, but now I need to name my links.I have created some links in a menu which when in the app pop up showing the domain I want it to show some text and not the domain but still take you the domain for example just apple not apple.comHere is my code below:
@objc func openTapped() {
let ac = UIAlertController(title: "Open Page...", message: nil, preferredStyle: .actionSheet)
ac.addAction(UIAlertAction(title: "apple.com", style: .default, handler: openPage))
ac.addAction(UIAlertAction(title: "google.com", style: .default, handler: openPage))
ac.addAction(UIAlertAction(title: "outlook.com", style: .default, handler: openPage))
ac.addAction(UIAlertAction(title: "Cancel" , style: .cancel))
ac.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem
present (ac, animated: true)
}
func openPage(action: UIAlertAction) {
guard let actionTitle = action.title else { return }
guard let url = URL(string: "https://" + actionTitle) else { return }
webView.load(URLRequest(url: url))
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
title = webView.title
}
}