Hello Everyone, I wanted to show full screen of UI...
# ios
a
Hello Everyone, I wanted to show full screen of UIViewController and using below code to present new controller. But when I am setting modalPresentationStyle as fullScreen then it’s crashing while dismiss() of view. Looking for solution any help will be appreciated. (Other style working fine problem with fullScreen)
*let* scannerViewController = ImageScannerController(delegate: *self*)
scannerViewController.modalPresentationStyle = .fullScreen
self.present(scannerViewController, animated: *true*)
// for dismiss
self.dismiss(animated: *true*, completion: *nil*)
I am using kotlin multiplatform
n
self.dismiss
will try to dismiss your current view (self), not the
scannerViewController
a
@NicoLourenco I am using scannerview controller to dismiss
n
Is your delegate weak in
ImageScannerController
?
a
public weak var imageScannerDelegate: ImageScannerControllerDelegate?
yes
Copy code
struct ComposeView : UIViewControllerRepresentable {
    func makeUIViewController(context: Context) -> UIViewController {
        let iosPlatformInterfaceImpl = IosPlatformInterfaceImpl()
        let mainViewController = MainViewControllerKt.MainViewController(platformFeatureInterface: iosPlatformInterfaceImpl)
                iosPlatformInterfaceImpl.viewController = mainViewController // Pass the reference to the view controller
                return mainViewController
    }
    
    func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}

struct ContentView: View {
    var body: some View {
        ComposeView()
                .ignoresSafeArea(.keyboard) // Compose has own keyboard handler
    }
}

class IosPlatformInterfaceImpl : NSObject, CommonResourcesPlatformFeatureInterface, ImageScannerControllerDelegate,ScannerCallBack {
    func result() {
        viewController?.dismiss(animated: true){
            self.onCompletionn?(self.randomArrayValue())
        }
    }
    
    
    weak var viewController: UIViewController? // Reference to the view controller
    var onCompletionn: ((NSMutableArray) -> Void)?
    
    
    func openScannerAndGetScannedImages(onCompletion: @escaping (NSMutableArray) -> Void) {
        self.onCompletionn = onCompletion
        scanImage(completion: onCompletion)
    
    }
    
    func openCamera(onCompletion: @escaping (String) -> Void) {
        print("hi openCamera")
    }
    
    func scanImage(completion: @escaping (NSMutableArray) -> Void) {
        guard let viewController = viewController else { return }
//        let scannerViewController = DigioViewController()
//        scannerViewController.result = self
        let scannerViewController = ImageScannerController(delegate: self)
        scannerViewController.modalPresentationStyle = .fullScreen
        

        if #available(iOS 13.0, *) {
            scannerViewController.navigationBar.tintColor = .label
        } else {
            scannerViewController.navigationBar.tintColor = .black
        }
       
        self.onCompletionn = completion
        
        viewController.present(scannerViewController, animated: true)
        
       
    }
   
    func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithResults results: ImageScannerResults) {
       print("imageScannerController didFinishScanningWithResults")
//        scanner.dismiss(animated: true, completion: nil)
//        scanner.navigationController?.dismiss(animated: true)
        
        scanner.dismiss(animated: false){
            self.onCompletionn?(self.randomArrayValue())
        }
//        self.onCompletionn?(randomArrayValue())
    }
}
I am using kotlin multiplatform this is the approach
issue resolved by using overFullScreen
seems fullscreen needs to use navigationview to push the screen then it'll work