Questions tagged [uihostingcontroller]
78 questions
0
votes
0 answers
SwiftUI navigation does not work in iOS15
I am want to navigate from UIKIT view controller to SwiftUI screen.
On button Tap in UIVIewcontroller
-(IBAction)buttonTap {
let SwiftUIController = UIHostingController(rootView: swiftUIScreen())
…

IOSDev
- 205
- 2
- 10
0
votes
0 answers
SwiftUI CountryPicker does not work in UIKIT
I have a SwiftUI View called CountryPicker that I am using within a UIKIT project.
The CountryPicker works correctly within a pure SwiftUI project.
The problem is, when I try to use the same CountryPicker within UIKIT using
UIHostingController, the…

CableGuy
- 47
- 1
- 6
0
votes
0 answers
SwiftUI coordinates of a double tap inside a View pre iOS 16
I need to locate the position of the last double tap within a large view, and I'm limited in what I can do to achieve this result as follows:
I can't use DragGesture(minimumDistance: 0) simultaneously to a TapGesture(count: 2) because the drag…

Baffo rasta
- 320
- 1
- 4
- 17
0
votes
1 answer
Floating button changes position when keyboard is shown in iOS 16.4.1
I have a floating button that is created using the CGFloatingButton func in my iOS app. It is positioned at the bottom of the screen, and its position is defined using frame based on the view's bounds. It was working fine in previous versions of…

Xavier Duvan Melo
- 320
- 2
- 14
0
votes
0 answers
NavigationView inside UIHostingController inside UITabBarController (SwiftUI inside objective C) adds gray bottom area
I have an app in Objectice C
I started to add some SwiftUI views
Everything works great but when I add a NavigationView inside the SwiftUI view automatically adds a gray space at the bottom that I cannot remove.
Other tabs that are in objective c…

Daniel Benedykt
- 6,496
- 12
- 51
- 73
0
votes
1 answer
Cannot Close SwiftUI View Embedded in UIHostingController
I've read just about every question and answer about closing a View that's loaded in a UIHostingController. They all seem to use some variation on using a button to dismiss the view. In my view the user is uploading an object and on completion I'd…

mystic cola
- 1,465
- 1
- 21
- 39
0
votes
0 answers
Attempt to present on (from UIHostingController) whose view is not in the window hierarchy
My goal is to display UIViewController (UIKit) on SwiftUI View.
My entire application is written in SwiftUI, but I use a library whose methods only take UIViewController's as input.
I tried to convert SwiftUI View to UIViewController by…

Evgeniy
- 1
0
votes
1 answer
SwiftUI in Storyboard Project Comes Up Blank
I'm following this tutorial:
https://www.youtube.com/watch?v=aWL7W8SLfeo
...on importing a SwiftUI file into an existing Storyboard project. When it didn't work in my existing project I made a brand new one from scratch (Xcode 13.2.1) and it doesn't…

mystic cola
- 1,465
- 1
- 21
- 39
0
votes
0 answers
Creating an Onboarding Scene and facing difficulties with the UIHostingController
I'm trying to create an onboarding screen using this (https://blckbirds.com/post/how-to-create-a-onboarding-screen-in-swiftui-1/) tutorial. I have the below code in my SceneDelegate, but I'm getting the following error, "Cannot find…

Parker
- 1
- 1
0
votes
2 answers
Status Bar is transparent with UIHostingController
The following is a simplified project to highlight the problem, which I have in a real project.
I have a project, where I add a SwiftUI view with UIHostingController, and the status bar at the top is transparent. I see it when I scroll the SwiftUI…

Ivan C Myrvold
- 680
- 7
- 23
0
votes
1 answer
UIHostingController size too big
I'm trying to embed a SwiftUI View within a UIKit UIView, within a View again. It will look something like this:
View
↓
UIView
↓
View
Current code:
struct ContentView: View {
var body: some View {
Representable {
Text("Hello…

George
- 25,988
- 10
- 79
- 133
0
votes
1 answer
How to separate a dismiss button from the main struct of a swiftui view (that is presented by a uihostingviewcontroller) to its own struct?
I am presenting and dismissing a swiftUI view with a button, and it works fine.
The swiftUI view:
struct SmartG_SwiftUI: View {
var dismissAction: (() -> Void)
var body: some View {
Button(action: {
dismissAction()
…

Abv
- 354
- 2
- 13
0
votes
1 answer
Present a UIViewController from a UIHostingViewController
I'm starting to rebuild my app from Swift to SwiftUI.
I have one UIViewController that is built using UIPresentationController and has custom drag gestures that I would like to use as-is (for now).
I'm trying to figure out if I am able to present…

Luke Irvin
- 1,179
- 1
- 20
- 39
0
votes
0 answers
Present embedded SwiftUI Subview in Full Screen, UIHostingController
I work on a Storyboard Swift App want to present a SwiftUI Subview in Full-Screen. I embedded the SwiftUI View using UIHostingController, like this:
let contentView = UIHostingController(rootView: ContentView())
override func viewDidLoad() {
…

MunichCoder
- 143
- 1
- 9
0
votes
0 answers
How to Present a UIDocumentInteractionController from a SwiftUI View
I have the following code that takes a screen shot of a SwiftUI View and I would like to present this screen shot in a UIDocumentInteractionController. I have done this in a UIKit ViewController and I would like to know if there is a way to convert…

Dogahe
- 1,380
- 2
- 20
- 50