Questions tagged [uiviewrepresentable]

229 questions
5
votes
0 answers

Struggling to implement PDFView in SwiftUI

I am trying to display a PDF in a SwiftUI view. When trying to implement other solutions here, I get the error Missing arguments for parameters 'PDFName', 'DisplayName' in call Errors image I assume that the way you use PDFView() has changed with…
5
votes
1 answer

SwiftUI UIViewRepresentable PDFKit PDFView AttributeGraph: cycle detected through attribute

Edit: Created a sample project illustrating the issue: https://github.com/Harold-D/PDFView_Representable Question: I'm at a lost, I have this very simple UIViewRepresentable wrapper around PDFView in SwiftUI import PDFKit import SwiftUI struct…
DIJ
  • 347
  • 4
  • 19
5
votes
4 answers

NavigationView embedded in a UIHostingController has additional safe area insets

Anyone know how to deal with this? Seems as though when you have a UIHostingController with a NavigationView the following happens: Notice the big grey tab bar safe area. This is primarily a UIKit application. Were replacing on of our tabs in the…
Xaxxus
  • 1,083
  • 12
  • 19
5
votes
1 answer

SwiftUI Button with UIView

I am making a SwiftUI Button from a custom UIButton class called UIPillButton. Here is the code for creating the SwiftUI button: Button(action: { print("Button tapped") }) { PillButton() .padding(.top) } Here is my class for…
Caleb Rudnicki
  • 345
  • 8
  • 17
5
votes
3 answers

Can I use the Snapchat SDK (SnapKit) with SwiftUI?

I'm trying to integrate Snapkit with an iOS app but I want to use SwiftUI instead of UIKit. I've already done the required setup with Snapkit and now I'm trying to get the snapchat login button to display in my app. I know the Snapkit SDK is made…
bze12
  • 727
  • 8
  • 20
5
votes
0 answers

SwiftUI UITextView wrapper how to size it content to match parent

I have such UITextView wrapper and it works but when I place it inside List row. I would like it to autosize, i.e. have width that match parent in this case List Row VStack { }, and height that is autosize based on text length. Text should wrap.…
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
5
votes
2 answers

SwiftUI Custom TextField with UIViewRepresentable Issue with ObservableObject and pushed View

I created a UIViewRepresentable to wrap UITextField for SwiftUI, so I can e.g. change the first responder when the enter key was tapped by the user. This is my UIViewRepresentable (I removed the first responder code to keep it simple) struct…
sinalco12
  • 248
  • 1
  • 4
  • 11
4
votes
1 answer

Self-Resizing UIView inside SwiftUI

I'm giving up on finding sources on the internet because it is difficult to find my specific case. I'm also new to SwiftUI. So I have a custom textfield wrapped within a custom UIView including its error text like this. Basically it just an…
Bobbyphtr
  • 115
  • 6
4
votes
0 answers

Interacting with a SwiftUI view below a UIKit PKCanvasView

I have a view Structure as follows: ZStack { UIKitView //PKCanvasView .zIndex(1) SwiftUIView //SwiftUI view which has a gesture recogniser .zIndex(0) } I wanted to know what the best way was to allow simultaneous…
santi.gs
  • 514
  • 3
  • 15
4
votes
2 answers

Type 'TextView' does not conform to protocol 'UIViewRepresentable'

I started to experiment SwiftUI stuff in a new clean project. Inside this new project, created a struct that conforms to UIViewRepresentable. The idea is to embed a UIKit view inside a SwiftUI view. Everything works fine. import SwiftUI struct…
DDelforge
  • 558
  • 7
  • 18
4
votes
2 answers

UIViewRepresentable not updating binding to ObservedObject property?

This view is a UIKit slider adapted to my SwiftUI project because in SwiftUI Slider cannot change its track color, which is probably a bug since you should be able to change it with .accentColor. Anyway, this slider changes its track color according…
4
votes
2 answers

Tapping an MKMapView in SwiftUI

I have a map in a SwiftUI app. It is working up to a point; but now I want to be able to tap on it and know the latitude and longitude of the tap. Here is the current code: import SwiftUI import MapKit struct MapView: UIViewRepresentable { …
Michel
  • 10,303
  • 17
  • 82
  • 179
4
votes
1 answer

How do I get my UIView to correctly size for its content in SwiftUI?

I want to use the awesome MultiSegmentPicker written by Yonat Sharon in my SwiftUI View. https://github.com/yonat/MultiSelectSegmentedControl However, I don't fully understand the interaction between the UIViewRepresentable View and my SwiftUI View.…
Mozahler
  • 4,958
  • 6
  • 36
  • 56
4
votes
2 answers

Saving PencilKit image – SwiftUI

I have a SwiftUI view to capture a user signature using a UIViewRepresentable PencilKit view. The view is capturing the signature just fine, but when I try to save the signature, the file saved is a blank/empty PNG file. import PencilKit struct…
Dwillmore
  • 65
  • 1
  • 7
4
votes
4 answers

Swipe between two pages with Segmented-style Picker in SwiftUI

I have a Picker with .pickerStyle(SegmentedPickerStyle()) to make it a segmented control. I want to make the pages smoothly swipe between, rather than replacing the view using a conditional statement. Here is a gif of what I have made so far: Here…
George
  • 25,988
  • 10
  • 79
  • 133
1
2
3
15 16