1

I have a simple SwiftUI wrap with UIKit as display on Playground (using Xcode 12.1)

import UIKit
import PlaygroundSupport
import SwiftUI

struct ContentView: View {

    var body: some View {
        WrapView()
    }
}

struct WrapView: UIViewRepresentable {
    func makeUIView(context: Context) -> UIView {
        print("makeUIView")
        return UIView(frame: .infinite)
    }
    func updateUIView(_ uiView: UIView, context: Context) {
        print("updateUIView")
    }
}

PlaygroundPage.current.setLiveView(ContentView())

I'm surprised to see so many calls to makeUIView and updateUIView as shown below

makeUIView
updateUIView
makeUIView
updateUIView
makeUIView
updateUIView
makeUIView
updateUIView
updateUIView
updateUIView
updateUIView
updateUIView
Elye
  • 53,639
  • 54
  • 212
  • 474
  • It is specific to PlaygroundPage, and, actually, you should not care about that - just do what is required in each method. – Asperi Nov 05 '20 at 11:44

0 Answers0