Questions tagged [uiviewrepresentable]
229 questions
1
vote
1 answer
UIViewRepresentable.updateUIView(_:context:) is not called when @State, @Binding or @EnvironmentObject are changed
UIViewRepresentable.updateUIView is not called when an ObservableObject is changed that this view and its parent view depend on.
I have a GameView that has "@State var locationManager: LocationManager" which is passed to my MapView as a binding. The…

Roman Reimche
- 143
- 1
- 13
1
vote
2 answers
How to hide navigationBar in SwiftUI when parent Views are with titles
I'm trying to make a simple app using SwiftUI using NavigationView and the last View is a video player (which I obviously don't want to have a navigationBar). The thing is that every other View leading to the player has navigationBarTitle and it…

Steph
- 11
- 1
- 2
0
votes
0 answers
Detect when picker is opened when tapping on a textfield
I'm trying to implement a textField that opens a menu style picker when you tap on it. One of the requirements is to be able to detect when the picker is opened/closed and perform custom actions to update the UI. This doesn't seem to be possible…

iamarnold
- 705
- 1
- 8
- 22
0
votes
1 answer
How to make a custom UIViewRepresentable fill its parent VStack and have custom subview centered in it?
So I have the following in my project.
ContentView ~ contains 3 vstacks.
CustomView ~ a custom view with a containerView with fixed size of 300x300 that should always be centered in ContentView
CustomViewRepresentable ~ a UIViewRepresentable in…

batman
- 1,937
- 2
- 22
- 41
0
votes
1 answer
SwiftUI - Updating a UIView wrapped in a UIViewRepresentable with a @Published var from a ViewModel?
So basically I'm wrapping a pretty simple UIKit component for it to be used within a SwiftUI view. Context goes as follows:
The component expects a UIImage as a parameter in its initializer but I wish to initialize it with a blank UIImage() and…

stompy
- 227
- 1
- 13
0
votes
0 answers
I am Using LazyHGrid / LazyHStack inside Custom ScrollView(UIScrollView), but lazy nature is not working
Can anybody tell me how can i set offset in a ScrollView?I have checked ScrollTo(), which scroll to index wise. But I want to move scrollview with offset. I have also checked Custom ScrollView( from UIScrollView) which can be used to set and get…
0
votes
0 answers
AVCapturePreviewLayer by uiviewrepresentable very slow
I'm making camera app using swiftui.
Because of performance issue, I'm trying to show preview using AVCapturePreviewLayer.
I found the way in stackoverflow and It worked.
Basically, I have a root ContentView.
when I tap button Navigation goes to…

Leo
- 1
0
votes
2 answers
SwiftUI UIViewRepresentable VideoPlayer updateUiView function causes infinite loop
I'm trying to implement a custom video player by using UIViewRepresentable.
I have the following implementation:
class PlayerUIView: UIView {
var videoName: String
private let playerLayer = AVPlayerLayer()
private var playerLooper:…

Marcel
- 472
- 2
- 6
- 19
0
votes
0 answers
Type '...View' does not conform to protocol 'UIViewRepresentable'
So I want to view pdf from core data but stuck on this issue
struct PDFView: View {
var pdfData: Data?
var body: some View {
if let pdfData = pdfData, let document = PDFDocument(data: pdfData) {
PDFKitView(document:…
0
votes
0 answers
Using custom views from AppKit and UIKit in a SwiftUI app
I have a multiplatform SwiftUI app which uses a custom view that is platform-specific in that it derives from NSView on macOS and UIView on iOS. These are legacy classes written in Objective-C & I'd like to use them in my SwiftUI app.
The…

jkcl
- 2,141
- 3
- 16
- 19
0
votes
1 answer
SWIFTUI ViewModifier using UIViewRepresentable; getting a value from the UIView to my SwiftUI View
I have a custom modifier on a SwiftUI View to pan and zoom an Image. I need to get the location where the user long presses. The modifier uses an UIView (UIViewRepresentable) under the hood where the pinch-and-zoom gesture is added to the view.…

DeveloperSammy
- 167
- 1
- 11
0
votes
0 answers
Swift video view will not show full height without explicitly setting it
I have a ScrollView which contains a series of views which contain videos. The setup is as follows:
I add the following to my ScrollView:
@ViewBuilder private var items: some View {
if let products = viewModel.allSortedExclusiveProducts {
…

DevB1
- 1,235
- 3
- 17
- 43
0
votes
1 answer
SwiftUI Formatting TextField for credit card input "xxxx-xxxx-xxxx-xxxx"
I want to write a custom TextField on SwiftUI to have an input with credit card format like this "xxxx-xxxx-xxxx-xxxx", I was looking at this answers https://stackoverflow.com/a/48252437, but I'm struggling with UIViewRepresentable, when I want to…

Arturiusz Pająk
- 9
- 1
- 1
- 3
0
votes
1 answer
UIViewRepresentable get data back to Swiftui without calling update view
I'm implementin ARKit and RealityKit, from ARKit I need the estimated light and that value has to goes back to the swiftui view. But as I'm doing each time the swiftui view is redrawn also in the UIViewRepresentable the delegate call updateUIView…

Nicola Rigoni
- 199
- 9
0
votes
0 answers
Change offset from UIViewRepresentable
I want to implement my own Offset-Modifier in SwiftUI using the current SwiftUI-View as a parameter and passing this own to a UIViewRepresentable-Wrapper to modify the frame of the SwiftUI-View in this wrapper.
I'm able to change e.g. the background…

Frank Marx
- 151
- 11