Questions tagged [uiviewrepresentable]
229 questions
2
votes
1 answer
SwiftUI custom Annotation map with SwiftUI
First of all before posting here I have read the StackOverflow rules for posting, anyway if I have done something wrong please comment it to edit the post.
Good morning || afternoon || evening, I have a question that I've been struggling with for a…

coden0w
- 31
- 6
2
votes
0 answers
how do I let users select text and bold, similar to Apple Notes
I am trying to create a note-taking app, but I can't figure out how to let the user format the text. Something like Apple Notes app, where I can select some text, bold/underline/strikethrough/italic the selected text only
I tried using UITextView as…

Stanley
- 21
- 3
2
votes
1 answer
Why does injections binding into UIViewRepresentable causes memory leak?
I've just started learning SwiftUI and I use Date Picker via UIViewRepresentable and I'm injection binding into it because I want to update my date property in View Model. When I open memory graph I see there is few instances of that view model so…

NikolaSwift
- 35
- 4
2
votes
1 answer
SwiftUI ScrollView not properly setting content offset when nested in UIViewRepresentable
I'm trying to introspect the UIScrollView under the hood of a SwiftUI ScrollView and that's all fine and dandy.
But I noticed that there were some issues with spacing and animation when scrolling going the pure representable approach so instead I'm…

Andrew Edwards
- 1,005
- 1
- 9
- 24
2
votes
1 answer
How can we show suggestions for UITextField is xCode Swift?
I have spent several hours on internet, but I am unable to find suitable solution for my problem. The problem is following:
I have implemented text filed, (with the help of stackoverflow post) using UIViewRepresentable, which wraps UITextField. I…

Tornike Shavishvili
- 1,244
- 4
- 16
- 35
2
votes
1 answer
SwiftUI MKMapView UIViewRepresentable - Simple App is crashing. Is this a 'Metal API' Library bug or did I do something obviously wrong?
I'm displaying a MKMapView in SwiftUI by wrapping it in the UIViewRepresentable protocol.
I think the crash may have something to do with "Metal API Validation Enabled"
I'm running Xcode Version 13.1 (13A1030d)
My iPhone is iOS 15.1
When I…

bhause
- 123
- 1
- 4
2
votes
0 answers
SwiftUI runtime crash ONLY IN IOS15 when using compositional layout with a uiviewrepresentable of collectionview
Getting a runtime crash when removing uiviewrepresentable of a collection view using compositional layout and a diffable data source from the screen. The view is currently in an if statement, if no data is found it uses a empty data view instead of…

Spencer Shelton
- 391
- 1
- 2
- 8
2
votes
0 answers
Why does a binding in UIViewRepresentables Coordinator have a constant read value
I have been writing a UIViewRepresentable and noticing some curios effects in regards to a binding I'm passing into the view.
When I read the bindings value in the coordinator through the saved UIViewRepresentable the value is always the value that…

Lumentus
- 71
- 6
2
votes
2 answers
@Published ObservableObject not updating SwiftUI View
I am working on SwiftUI and displaying MapView using UIViewRepresentable.
Now, when map is loaded then I am calculating route between two points and i am storing that route in model.
class MapInfo: ObservableObject {
@Published var routeArray:…

Programming Learner
- 4,351
- 3
- 22
- 34
2
votes
2 answers
SwiftUI + UIViewRepresentable: how would you have the UIViewRepresentable respond to a binding
Context
I am implementing a video player that should expose play, pause mute and unmute functions. In my case it would be ideal if these boolean settings are passed in as bindings. I have a basic UIViewRepresentable working here:
import…

xiaolingxiao
- 4,793
- 5
- 41
- 88
2
votes
1 answer
Can't use UIViewRepresentable based on UIView more than once in the same View
When I try to place several UIViewRepresentable views to ContentView, it's shown only the last one. Here is the code:
struct ContentView: View {
@State var customView = UIView()
var body: some View {
NavigationView {
…

Vyacheslav Burlakov
- 242
- 2
- 7
2
votes
1 answer
Custom Annotations in SwiftUI (MKMapView)
I have implemented a MKMapView in SwiftUI and I am showing a list of annotations (stops) as well as the user's location.
I wanted to add the tap functionality to the "stop pins" but I wasn't able to find anything helpful to achieve this.
The problem…

arata
- 859
- 1
- 8
- 23
2
votes
1 answer
Can't add Tap Gesture Recognizer to SwiftUI MKMapView UIViewRepresentable
I have a SwiftUI app with SwiftUI life cycle and I'm trying to get a tap gesture to
work in an MKMapView. I can't seem to get the reference to the map correctly. All I
want to do in this subsection is tap the map and add an annotation. I would…

JohnSF
- 3,736
- 3
- 36
- 72
2
votes
2 answers
SwiftUI Dismiss Keyboard from UITextField
So for my own reasons, I need the full control that UITextField and its delegates would normally offer, but the screen it's being added to is written with SwiftUI. Needs a .decimal keyboard, so no Return Key.
I have only 2 issues remaining, 1 of…

Joey Nash
- 41
- 1
- 4
2
votes
0 answers
SwiftUI UIViewRepresentable Not Scaling
I have created a WKWebView as a UIViewRepresentable in a SwiftUI app with SwiftUI life
cycle. It works for content. However, when I start the app in iPad landscape and rotate
to portrait the right side of the view is truncated. I have attempted to…

JohnSF
- 3,736
- 3
- 36
- 72