How can you use ContactAccessButton() or contactAccessPicker() with a storyboard?

I've got an existing app using storyboards and would like to incorporate the new iOS 18 ContactAccessButton() and contactAccessPicker() into the GUI. However, how can that be done? If I try to do something like add a UIView to a view controller in the storyboard, then ContactAccessButton can't be assigned to it (even though ContactAccessButton inherits from UIView). Nor can a ContactAccessButton be used as a type within the Storyboard/the View Controller.

How do I go about integrating this new iOS feature into an existing app using Storyboards and view controllers?

Answered by Frameworks Engineer in 803771022

ContactAccessButton is a SwiftUI View, so you can embed it in a UIKit view hierarchy programmatically using UIHostingController. It is not possible to use from a storyboard.

Accepted Answer

ContactAccessButton is a SwiftUI View, so you can embed it in a UIKit view hierarchy programmatically using UIHostingController. It is not possible to use from a storyboard.

Thank you that did the trick. However, do you happen to know the specifics of using ContactAccessButton via UIKit? If I display it, and click on its button, then I can see that its expecting a callback/delegate, however I don't see how to can add one programmatically using it in a UIViewController/UIView/Storyboard way.

How can you use ContactAccessButton() or contactAccessPicker() with a storyboard?
 
 
Q