Hello everyone reading out this post for me. I am new to swiftui. I want to connect a tab bar view controller to swift ui view. This is the swiftui view I want to incorporate in a tab bar view controller GitHub - khalid-asad/card-reader-ios: A credit card reader and parser for iOS Using Native Vision/VisionKit
I am facing problem in connecting a swiftui view with a tab bar view controller. This is what I have done so far.
Step1: I have created a hosting view controller. Step 2: established a root view controller relationship segue between the hosting view controller and navigation/tab bar controller. Step 3: Now i have a swiftUI view named as CardFormView that i want to link. Step 4: create a UIHostingController class and set the HostingViewController to that class in the class inspector.
This is how my hosting view controller file looks like
import UIKit
import SwiftUI
class HostingViewController: UIHostingController<CardFormView> {
required init?(coder aDecoder: NSCoder){
super.init(coder: aDecoder, rootView: CardFormView( completion: (CardDetails) -> Void))
}
}
But I am getting an error Cannot convert value of type ‘((CardDetails) → Void).Type’ to expected argument type ‘(CardDetails) → Void’
I am not able to understand this swiftui code much.
It would be helpful if I can get some help in understanding the library code. I have seen the functionality of this app and am familiar with the file types. But I am not sure how to fix this issue in order to connect a tab bar view controller to swiftui view successfully.
It would be helpful if i can get some help.