Post

Replies

Boosts

Views

Created

How can i fix error: Type 'YandexInter' does not conform to protocol 'UIViewControllerRepresentable'
I wrote the code. But i got error: Type 'YandexInter' does not conform to protocol 'UIViewControllerRepresentable'. How can i fix it? My code: struct YandexInter : UIViewControllerRepresentable { func makeUIViewController(context: Context) -> YMAInterstitialAd { let adViewAdIn = YMAInterstitialAd(adUnitID: "R-M-2248734-1") adViewAdIn.delegate = context.coordinator adViewAdIn.load() return adViewAdIn } func updateUIViewController(_ uiView: YMAInterstitialAd, context: Context) {} func makeCoordinator() -> Coordinator { Coordinator() } class Coordinator: NSObject, YMAInterstitialAdDelegate { var interstitialYandexAd: YMAInterstitialAd! func loadInterstitial(){ //self.interstitialYandexAd = YMAInterstitialAd(adUnitID: "R-M-2248734-1") //self.interstitialYandexAd?.load() self.interstitialYandexAd.delegate = self } func interstitialAdDidLoad(_ interstitialYandexAd: YMAInterstitialAd) { let scenes = UIApplication.shared.connectedScenes let windowScene = scenes.first as? UIWindowScene let window = windowScene?.windows.first let root = window?.rootViewController self.interstitialYandexAd.present(from: root!) print("Loaded Adv.") } func interstitialAdDidFail(toLoad interstitialYandexAd: YMAInterstitialAd, error: Error) { print("Loading failed. Error: \(error)") } func interstitialAdDidFail(toPresent interstitialAd: YMAInterstitialAd, error: Error) { print("Presenting failed. Error: \(error)") } } }
2
0
1k
Mar ’23
How to open the ContentView from a function when the Ok button is clicked?
There is such a function: func didFinishConfirmation(paymentMethodType: YooKassaPayments.PaymentMethodType) { DispatchQueue.main.async { [weak self] in guard let self = self else { return } let alertController = UIAlertController( title: "Confirmation", message: "Profit!", preferredStyle: .alert ) let action = UIAlertAction(title: "OK", style: .default) alertController.addAction(action) self.dismiss(animated: true) self.present(alertController, animated: true) } } How to make it so that when clicking on the Ok button when an alert appears, the ContentView () in SwiftUI opens?
1
0
413
Jun ’23