Questions tagged [uiviewrepresentable]

229 questions
1
vote
1 answer

Do something as soon as UIViewRepresentable is instantiated

This seems like a straightforward question, but I have not been able to find any solutions in the Swift docs. When I was programming in Kotlin, it was common to use the init() method of a class to perform some work in order to get the class set up…
John Harrington
  • 1,314
  • 12
  • 36
1
vote
0 answers

UI of Camera app frozen after user presses the "Use Image" button

In my camera app, I click a photo and press the use photo button. When the user presses the "Use Photo" button after clicking the photo, the photo gets saved in the photo library(if the user allows the app to) but the CameraView completely freezes.…
1
vote
2 answers

ype 'MapView' does not conform to protocol 'UIViewRepresentable'

In a clean demo project I've created a MapView which is UIViewRepresentable and it all works great. It reads a geojson file with a polygon and draws it on the map. When I copy this exact code to my bigger project where i need this functionality I'm…
Peter Van de Put
  • 878
  • 10
  • 26
1
vote
1 answer

Update UIView (inside UIViewRepresentable) when @Binding value changes

I try to update UIView (inside UIViewRepresentable) when the binding value changes, but I don't know how to catch the changes of the binding value to update the UIView? I used on receive function but a warning message showed say (the result of the…
Ammar Ahmad
  • 534
  • 5
  • 24
1
vote
0 answers

Start SwiftUI implementation of UIScrollView at specific scroll and zoom

I have some experience in SwiftUI, but am new to UIKit. I'd like to import the zoom and position from one instance of an UIViewRepresentable UIKit ScrollView to another. So, basically, the user scrolls and zooms and later, in another branch of the…
berrou
  • 11
  • 3
1
vote
0 answers

SwiftUI: UIPickerView row description with UIViewRepresentable

I implemented a UIPickerView in SwiftUI using UIViewRepresentable with following code: struct DurationPickerView: UIViewRepresentable { func makeUIView(context: Context) -> UIPickerView { let picker = UIPickerView() …
SwiftUI_Max
  • 201
  • 2
  • 6
1
vote
0 answers

SwiftUI UIViewRepresentable ScrollView is not zooming

I am developing an iOS app using the SwiftUI. I need to implement the "pinch to zoom" feature in the app so i tried using the SwiftUI's ScrollView but went in to the problems of not able to pinch and drag the content at the same time as discussed in…
Hariprasad
  • 1,094
  • 2
  • 12
  • 30
1
vote
0 answers

Unable to wrap multiline text from UITextView via UIViewRepresentable in SwiftUI

I have a UITextView via a UIViewRepresentable which should be able to display multiline text, but unfortunately, the text distorts the entire view by remaining in one single line and clipping out of bounds. I managed to get the view back to normal,…
Milly Alfaro
  • 299
  • 3
  • 15
1
vote
0 answers

SwiftUI UIViewRepresentable AVPlayer crashing due to "periodTimeObserver"

I have a SwiftUI application which has a carousel of videos. I'm using an AVPlayer with UIViewRepresentable and I'm creating the carousel with a ForEach loop of my custom UIViewRepresentable view. I want to have a "periodicTimeObserver" on the…
JefeFA
  • 11
  • 2
1
vote
2 answers

SwiftUI UIView UIViewRepresentable not found in scope

I have an iOS app written in Swift and using UIKit I have now decided to add a watch extension (companion app) also written in swift, but using SwiftUI, instead of UIKit When I try to bring a UIKit view into SwiftUI (UITextView) using…
1
vote
1 answer

UIPickerView with UIViewRepresentable does not fill the whole width

Unfortunately, when I create a UIPickerView in SwiftUI with UIViewRepresenable it doesn't fill the whole screen. I've also tried giving it a lot of frame modifiers, but nothing worked. Does anyone have a solution for this or knows why the width of…
Tom_Swift
  • 87
  • 6
1
vote
0 answers

How to mimic SwiftUI List's data-less initializers when wrapping UITableView

Apple offers the following SwiftUI List initializer: List.init(selection: Binding?, content: () -> Content) I would like to make a similar component, but customizing some of the UITableView…
kamcma
  • 203
  • 3
  • 5
1
vote
1 answer

How do I declare a view so it's initialization and itself are NOT in the representable view?

I have a UIKit representable view for using Mapbox in my SwiftUI app and control the mapView from inside the Coordinator by passing the MapboxViewRepresentable View itself when making the coordinator. The problem I am having is that the mapView, its…
Jake Smith
  • 580
  • 3
  • 11
1
vote
0 answers

Determine UIViewRepresentable with a custom UIView size dynamically

I have an issue when trying to convert a custom View that inherits from UIView into a SwiftUI view, the view takes the whole screen. But it works pretty well if I inherit from UILabel instead of UIView. Note This view is shown inside a…
Bathant Hegazy
  • 549
  • 4
  • 16
1
vote
1 answer

Prevent updateUIView to update view when @State var changes

After reading other questions and google around, i think its safe to say that updateUIView will be triggered as soon as any @state/@Binding var is changed in UIViewRepresentable no matter what. In my case i don't want to trigger updateUIView on one…
Joe
  • 173
  • 1
  • 15