Merhaba Xcode ile webview olarak url çağırdığım bir app var, headerde youtube Linki ekledim ama bunu webview içinde açıyor.
Kullanıcıda yüklü ise YouTube uygulamasına değilse Tarayıcıda yeni sekmede Youtube sitesine nasıl atarım ? örnek kod varsa sevinirim
tşk ederim
webview ile YouTube Uygulamasına geçiş yapma
4
●122
- 26-07-2024, 17:07:15
- 26-07-2024, 17:31:07Yok hocam bu klasik php için geçerli. farklı benim sorduğum soru.php_bot adlı üyeden alıntı: mesajı görüntüle
- 26-07-2024, 17:38:03Yanlış görmüşüm pardon
if UIApplication.shared.canOpenURL(url) { let appURL = URL(string: "youtube://\(urlString)")! if UIApplication.shared.canOpenURL(appURL) { UIApplication.shared.open(appURL, options: [:], completionHandler: nil) } else { UIApplication.shared.open(url, options: [:], completionHandler: nil) } } - 26-07-2024, 18:06:42Kendi uygulamamda kullandığım bir kod örneği vereyim swift ile yapıyorum benDusLerforum adlı üyeden alıntı: mesajı görüntüle
import UIKit import WebKit class ViewController: UIViewController, WKNavigationDelegate { @IBOutlet weak var webView: WKWebView! override func viewDidLoad() { super.viewDidLoad() webView.navigationDelegate = self // WebView içinde gösterilecek URL let url = URL(string: "https://www.example.com")! let request = URLRequest(url: url) webView.load(request) } @IBAction func openYouTubeLink(_ sender: UIButton) { let youtubeURL = URL(string: "youtube://videoid")! let youtubeWebURL = URL(string: "https://www.youtube.com/watch?v=videoid")! if UIApplication.shared.canOpenURL(youtubeURL) { UIApplication.shared.open(youtubeURL, options: [:], completionHandler: nil) } else { UIApplication.shared.open(youtubeWebURL, options: [:], completionHandler: nil) } } }