Questions tagged [uiviewrepresentable]

229 questions
4
votes
2 answers

SwiftUI Wrapped SearchBar Can't Dismiss Keyboard

I am using a UIViewRepresentable to add a search bar to a SwiftUI project. The search bar is for searching the main List - I have setup the search logic and it works fine, however I have not been able to code the keyboard to disappear when the…
JohnSF
  • 3,736
  • 3
  • 36
  • 72
3
votes
1 answer

UIViewRepresentable - MKMapView doesn't get updated

I'm dealing with an app where I have to embed a MKMapView (UIKit) into a SwiftUI View. Unfortunately I can't use the implemented Map of SwiftUI, because I have to support clustering (which Map can't do at the moment). The problem is, that the…
finebel
  • 2,227
  • 1
  • 9
  • 20
3
votes
1 answer

How do I display WKWebView url?

I was wondering how I can display my current URL on WKWebView and display URL on change also. Currently I added a Text() but it does not display the URL at all. Any ideas how I can fix it? WebView import SwiftUI import WebKit struct WebView :…
James Lee
  • 656
  • 1
  • 7
  • 22
3
votes
1 answer

MFMessageComposeViewController + SwiftUI Buggy Behavior

I'm using ViewControllerRepresentable to present a MFMessageComposeViewController so users can send texts from my app. However, every time the view is presented, it's very buggy - elements randomly disappear, scrolling is off, and the screen…
3
votes
4 answers

Cursor always jumps to the end of the UIViewRepresentable TextView when a newline is started before the final line + after last character on the line

I’m depending on the TextView using UIViewRepresentable created here https://www.appcoda.com/swiftui-textview-uiviewrepresentable/. struct TextView: UIViewRepresentable { @Binding var text: String @Binding var textStyle:…
Barrrdi
  • 902
  • 13
  • 33
3
votes
0 answers

Touches/Gestures in SwiftUI and UIView(Controller)Representable aren't recognised at the same time

I have controls inside both SwiftUI views as well as UIKit VCs and views that are embedded inside UIView(Controller)Representable. In my (music) app it's common for the user to interact with multiple controls at the same time, e.g. tweaking knobs or…
3
votes
1 answer

Using PKToolPicker without PKCanvasView

I am trying to use PKToolPicker from PencilKit (iOS/Swift) from a custom view (which is NOT PKCanvasView). The custom view conforms to PKToolPickerObserver. Everything works fine during compile time but I never get to see the PKToolPicker! If I…
Arshia
  • 334
  • 2
  • 13
3
votes
1 answer

UITextView with NSMutableAttributedString with Link SwiftUI

I have this Custom UITextView that uses "ShouldInteractWith" method: class StudyText: UITextView, UITextViewDelegate { func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction:…
Kevin
  • 1,103
  • 10
  • 33
3
votes
0 answers

Finger and Pencil width on PKCanvasView Different

I am trying to build out an application with the ability to use both apple pencil and finger input to draw. However, when I set the width of the tool to a sufficiently small number (1) the pencil input displays correctly, but when I use my finger it…
balt2
  • 75
  • 5
3
votes
1 answer

How to make UIViewRepresentable focusable on tvOS in SwiftUI?

The title says it all - I can't get focus on UIViewRepresentable in SwiftUI on tvOS. Any view that conforms to View protocol can be focused without problems but neither UIViewRepresentable nor UIViewControllerRepresentable can. Any ideas? This code…
gutaker
  • 181
  • 3
  • 10
3
votes
0 answers

Binding not updated immediately inside updateUIView in UIViewRepresentable

I am adapting a Swift Project to SwiftUI. The original project has Drag and Drop on UIImages, drawing and some other manipulations which aren't possible in SwiftUI. The code below is for explaining the problem only. Working code on: …
Victor Sanchez
  • 960
  • 2
  • 12
  • 26
3
votes
2 answers

evaluateJavaScript in swiftui

How to get evaluateJavaScript to work when a message is received from webview? print(message.body) <--- this is working parent?.evaluateJavaScript("document.getElementsByClassName('mat-toolbar-single-row')[0].style.backgroundColor = 'red'",…
Nouras
  • 129
  • 2
  • 12
3
votes
1 answer

SwifUI using UIKit components by implementing UIViewRepresentable

Ok I know how to wrap UIKit components like TextField to use with SwiftUI using UIViewRepresentable and Coordinator. And it all works well. But how can I customise this components from SwiftUI perspective in way that is native to SwiftUI i.e. using…
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
2
votes
0 answers

Creating a PKCanvasView in swiftUI makes the screen flickers

I have a SwiftUI view that uses a PKCanvasView However, I am receiving an error in the logs 2023-05-07 01:06:14.413211-0700 [24247:15704822] Metal API Validation Enabled 2023-05-07 01:06:16.157795-0700 [24247:15705030] [] Failed to allocate an…
Blacksmith
  • 199
  • 7
2
votes
0 answers

How to implement a lazy-loading ScrollView with UIViewRepresentable with SwiftUI?

I'm trying to implement a lazy-loading MyLazyHStack view using UIViewRepresentable, but it's not loading the elements lazily. I'm using LazyHStack in the content of MyLazyHStack, but all the elements are loading at once instead of loading lazily as…
Martin Romañuk
  • 1,039
  • 10
  • 14
1 2
3
15 16