diff --git a/Introspect/UIKitIntrospectionView.swift b/Introspect/UIKitIntrospectionView.swift index 236abae9..9d9765fe 100644 --- a/Introspect/UIKitIntrospectionView.swift +++ b/Introspect/UIKitIntrospectionView.swift @@ -67,15 +67,18 @@ public struct UIKitIntrospectionView: UIViewRepresentabl /// `makeUIView`, so we need to call the handler again to allow re-customization /// based on the newest state. public func updateUIView( - _ uiView: IntrospectionUIView, + _ view: IntrospectionUIView, context: UIViewRepresentableContext ) { - uiView.moveToWindowHandler?() + guard let targetView = self.selector(view) else { + return + } + self.customize(targetView) } /// Avoid memory leaks. - public static func dismantleUIView(_ uiView: IntrospectionUIView, coordinator: ()) { - uiView.moveToWindowHandler = nil + public static func dismantleUIView(_ view: IntrospectionUIView, coordinator: ()) { + view.moveToWindowHandler = nil } } #endif diff --git a/Introspect/UIKitIntrospectionViewController.swift b/Introspect/UIKitIntrospectionViewController.swift index 4d8f1d34..a0e20d7b 100644 --- a/Introspect/UIKitIntrospectionViewController.swift +++ b/Introspect/UIKitIntrospectionViewController.swift @@ -59,7 +59,10 @@ public struct UIKitIntrospectionViewController ) { - (viewController.view as? IntrospectionUIView)?.moveToWindowHandler?() + guard let targetView = self.selector(viewController) else { + return + } + self.customize(targetView) } /// Avoid memory leaks.