Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couple of bugs in the UIViewRepresentable implementation #3

Open
malhal opened this issue Apr 12, 2023 · 0 comments
Open

Couple of bugs in the UIViewRepresentable implementation #3

malhal opened this issue Apr 12, 2023 · 0 comments

Comments

@malhal
Copy link

malhal commented Apr 12, 2023

This:

struct ARViewContainer: UIViewRepresentable {
    var arView = ARView(frame: .zero)

Should be:

struct ARViewContainer: UIViewRepresentable {
    func makeUIView(context: Context) -> ARView {
        let arView = ARView(frame: .zero)

"Make" means init the UIView in this func.

Also:

    func makeCoordinator() -> Coordinator {
        Coordinator(parent: self)
    }

Should be:

    func makeCoordinator() -> Coordinator {
        Coordinator()
    }

self is referring to this struct value type which is out-of-date whenever this ARViewContainer is re-init by the parent View's body. You need to implement updateUIView and set all of this structs values on the ARView and/or the coordinator object (if they have changed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant