Questions tagged [uiviewrepresentable]

229 questions
0
votes
1 answer

WKWebView iOS linking Javascript File

I'm having trouble getting a javascript file to run from inside a UIViewRepresentable WKWebView. This is probably a simple question with a simple answer, but I cannot seem to figure this out. I'm new to Swift and iOS programming. I'd like to link to…
kanja klub
  • 121
  • 1
  • 1
  • 12
0
votes
1 answer

swftUI UIViewRepresentable transform deleted text in strikethrough with custom tag

i am building a custom text editor. I would like when I delete some text, not delete it but transform it into a text with the strikethrough attribute but through a tag not visible in the editor. Example: Lorem ipsum dolor sit amet. Vestibulum…
Stefano Vet
  • 567
  • 1
  • 7
  • 18
0
votes
2 answers

UIViewRepresentable UICollectionView How do you scroll to a certain point when view appears?

I have the following code, but I am not sure where to place it in my UIViewRepresntable. Any suggestions? let scrollTo = IndexPath(row: 25, section: 0) view.scrollToItem(at: scrollTo, at: .top, animated: false) struct…
Yrb
  • 8,103
  • 2
  • 14
  • 44
0
votes
1 answer

How to combine UIViewRepresentable and instance methods for Mapkit?

For an app I need to display a Map from mapkit. I'm using SwiftUI. On top of the Map itself there need to be a search function and when you finish the search (enter) the map moves the visible region to the result of the search import MapKit import…
Peter Van de Put
  • 878
  • 10
  • 26
0
votes
1 answer

Dismiss UIViewRepresentable using onChange method is Not working

I have a UIViewRepresentable and need to dismiss when some value has changed.I used .onChange method and it is not working. But onChange method called successfully. Main View class ViewModel:ObservableObject { @Published var urlHasChanged:Bool =…
Dilan
  • 2,610
  • 7
  • 23
  • 33
0
votes
1 answer

Setting contentOffset for UIViewRepresentable ScrollView (SwiftUI)

Problem I'm trying to start an UIViewRepresentable ScrollView with a given zoom and position. I set the new zoom and new contentOffset in the makeUIView, but the setContentOffset call has no VISUAL effect and when zooming back out from the new zoom,…
berrou
  • 11
  • 3
0
votes
1 answer

Binding not working in UIViewRepresantable

I am trying to make a custom textfield using UIViewRepresantable but when I enter value in textfield, it is not reflecting in the root @State variable: struct UiKitTextField: UIViewRepresentable { @Binding var amount: Double class…
Wahid Tariq
  • 159
  • 10
0
votes
1 answer

Map become gray when keyboard appear swiftui

I'm experience a strange behavior on my app view, as you can see from the attached gif when the keyboard appear the map will become gray. What can be the issue and possible solution. here my view code. struct CreateYourFarm: View { …
Damiano Miazzi
  • 1,514
  • 1
  • 16
  • 38
0
votes
1 answer

Swift UITapGestureRecognizer not calling

Pretty simple problem that is making out to be harder to solve than it should: My gesture is simple not calling, at all. I am using a uiviewrepresentable that is displayed inside of a zstack. If i add a .tapgesture{} to CameraView() directly it…
Trevor
  • 580
  • 5
  • 16
0
votes
1 answer

UIScrollView embedded in SwiftUI has zero size

I need to embed an UIScrollView in a SwiftUI view hierarchy. I wrapped one in UIViewRepresentable, but for some reason my scroll view has zero width. How do I make the connection between the outer SwiftUI views and the autolayout constraints that…
Rob N
  • 15,024
  • 17
  • 92
  • 165
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
0 answers

UIViewRepresentable: Reloading data in UICollectionView from updateUIView fails, app crashes

I'm working with a UICollectionView as UIViewRepresentable. It should be updated when either current item is changed (to scroll to the current item and highlight it), or the source data was updated (it can add/remove one item). The first case works…
0
votes
0 answers

Add marker over an image that is embedded inside a scrollview in swiftui

Unlike the markers over a map, I was trying to add markers over an image that is embedded in a scroll view ( for zooming and panning ). I'm using an UIViewRepresentable to achieve the scroll functionality and tap gesture functionality. Wanted to…
0
votes
1 answer

SwiftUI and UIKit Interoperability with displaying multiple views

Overview: I'm using SwiftUI, but wanted to use UIKit-MapKit. I used UIViewRepresentable to be able to wrap the UIKit feature. Problem: I'm learning about swiftui-uikit-interoperability and I'm getting stuck on being able to display multiple SwiftUI…
0
votes
1 answer

How can I show/hide the title of my MKPointAnnotation() pin after I set it inside of my UIViewRepresentable updateUIView (SwiftUI)?

I would like to toggle the visibility of the title of my MKPointAnnotation after I tap the pin. I tried changing the title directly in func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) but it tells me that it's only a get property…
RapsIn4
  • 91
  • 5