Open yimajo opened 11 months ago
I have the exact same issue. I spent four days trying to figure out why my UIViewControllerRepresentable
view didn't work as expected. Turns out that viewDidAppear(animated:)
is never called, and neither is viewWillAppear(animated:)
. I wonder if it's because SwiftUI itself provides .onAppear()
...
I am facing the same behavior as @mtehsiang
I tried with Xcode 15.2 and iOS 17.2.1, but the lifecycle is still not working.
If this is not fixed, I can't use Google AdMob type custom ViewController in SwiftUI.
Details
Description
When the tabViewStyle modifier for SwiftUI's TabView to something other than normal, the
UIViewControllerRepresentable
ViewController that configures the TabView will not be able to callviewWillAppear
andviewDidAppear
.In other words, the lifecycle methods will not be called properly. This makes it impossible to use UIKit to compensate for the missing parts of the SwiftUI, and also makes it impossible for third-party libraries to work properly.
The sample code that reproduces the problem is as follows, and it reproduces both in Xcode 14.3.1 and Xcode 15 Beta 5. It is also reproduced on both simulators and devices.
Development environment
Files