Questions tagged [uiviewrepresentable]
229 questions
0
votes
1 answer
NSUnknownKeyException when connecting property IB
I am trying to integrate a UIKit view into my SwiftUI project using UIViewRepresentable as an intermediate.
A TestViewVC.swift file was created containing just a simple IBOutlet:
import Foundation
import UIKit
class TestViewVC: UIViewController {
…

keith.g
- 900
- 9
- 19
0
votes
1 answer
UIViewRepresentable: Cannot use mutating member on immutable value: 'self' is immutable
I want to create a custom textfield for SwiftUI by using UIViewRepresentable. To handle the didBeginEditing and didFinishEditing actions I subscribed to the publishers that I previously created as an extension to the UITextField class. So I put the…

Heimdallr
- 189
- 1
- 14
0
votes
0 answers
UIViewRepresentable and UILabel resizing behaviour
I'm building a UILabel based SwiftUI view using UIViewRepresentable on an app that has a minimum deployments target set to iOS 14.
The code of the View is:
struct MyLabel: View {
@State private var size: CGSize? = SizeKey.defaultValue
@State…

Luca Bartoletti
- 2,435
- 1
- 24
- 46
0
votes
0 answers
Why doesn't my UIViewRepresentable button handle VoiceOver tap actions?
I am trying to reuse a custom UIKit control in a SwiftUI screen, so I have wrapped it in a UIViewRepresentable struct. However, it does not respond to accessibility tap gestures (double-tap while VoiceOver is enabled).
My code is like
struct…

Greg
- 10,360
- 6
- 44
- 67
0
votes
1 answer
AVQueuePlayer play/pause methods not updating UI
I have a looping video player that should play or pause based on a given isPlaying property. I initially created a looping video player (similar implementation to this example) -- now I want the ability to pause it.
The UI initializes the video in…

Jake Loew
- 81
- 7
0
votes
1 answer
Content offset issue in wrapped UIScrollView during transition from the bottom of the screen in SwiftUI
Description
I am using a custom UIScrollView with custom content in a popup view that transitions from the bottom of the screen. However, each time it animates, the content within the UIScrollView appears to offset its position when reaching the top…

Hollycene
- 287
- 1
- 2
- 12
0
votes
0 answers
State does not update immediately when Binding is changed in UIViewRepresentable
I want a UITextView with its height wrapped to the content inside. And this solution works just fine.
However, it breaks when there are multiple such views, say, in a VStack.
In iOS 16 UIViewRepresentable has a method sizeThatFits(_:uiView:context:)…

ikroop
- 96
- 1
- 6
0
votes
0 answers
UIKit pinch gesture in a mixed SwiftUI / UIKit environment presents issues with scaleEffect, anchor and offset
Apple provides some elegant code for managing pinch gestures in a UIKit environment, this can be downloaded directly from Apple. In this sample code you will see three coloured rectangles that can each be panned, pinched and rotated. I will focus…

Juan
- 140
- 7
0
votes
1 answer
UITapGestureRecognizer not triggered when used by 2 overlapping UIViewRepresentable
Because I need to know whether user taps with finger or pencil, I had to create a UIViewRepresentable with a UITapGestureRecognizer. Everything works fine when this View is used with other SwiftUI views. But when stack 2 of this view, and I clip the…

MohG
- 351
- 4
- 11
0
votes
1 answer
How to clear all text in a UIViewRepresentable Text Field with a view modifier
I'm trying to delete all text inside a Text Field when a button to the right of the text field is tapped. When I tap the clear button it behaves as though the text has been cleared. It shows the placeholder text which is set to be shown when the…

Tirna
- 383
- 1
- 12
0
votes
1 answer
How to pass a string inside a class that is inside a struct?
struct WebView: UIViewRepresentable {
@Binding var response: String
func makeUIView(context: Context) -> WKWebView {
let webConfiguration = WKWebViewConfiguration()
let wkController = WKUserContentController()
…

David Leyva Abrahantes
- 13
- 1
- 5
0
votes
1 answer
Google Maps SDK heatmap wont update upon array append
EDIT: Look at my comment in the solution to see what I changed in the updateUIView.
I am trying to update a heatmap I have on my map via a button press.
Here is how the screen looks:
GIF of how the screen and interaction look
I have the array that…

RocketBlaster05
- 3
- 4
0
votes
0 answers
Changing keyboard language using UIKit in SwiftUI (UIViewRepresentable)
I'm trying to change the on screen keyboard's language layout to a different language, when user taps on a foreign phrase text field. The foreign text field is the foreign equivalent of what they typed into another text field in their native…

Tirna
- 383
- 1
- 12
0
votes
2 answers
How to make UIViewRepresentable inherit UIView?
I have a UIViewRepresentable of a third-party library component FSCalendar. However, I need this to conform to type UIView... Is there a way to do this? Any help is appreciated :)
struct CalendarViewRepresentable: UIViewRepresentable {
…

devOP1
- 295
- 3
- 13
0
votes
1 answer
ImageAnalysisInteraction in UIViewRepresentable not working correctly
I have a simple UIViewRepresentable wrapper for the live text feature (ImageAnalysisInteraction). It was working without issues until I started updating the UIImage inside the updateUIView(...) function.
I have always been seeing this error in the…

fer0n
- 295
- 1
- 5
- 14