Questions tagged [uiviewrepresentable]

229 questions
1
vote
0 answers

Hot to set additional safe area insets in SwiftUI

I'm trying to add additional padding to safe area dynamically. To achieve this I wrote modifier that wraps SwiftUI view into UIHostingController and sets additionalSafeAreaInsets on them: extension View { func extendSafeArea() -> some View { …
1
vote
1 answer

SwiftUI NSViewRepresentable can't read data from @Publisher

I'm writing a ChartView using NSView with data obtained from a rest api using Combine. The struct PlotView is the SwiftUI View that displays the chart, ChartViewRepresentable is the bridge between the NSView with the chart and the SwiftUI world and…
Alejandro
  • 367
  • 3
  • 10
1
vote
0 answers

Simultaneous Gestures not working for a ZoomableScrollView in SwiftUI

Using Swift5.3.2, iOS14.4.1, Xcode12.4, I am trying to use the .simultaneousGesture modifier in SwiftUI. As far as I understood, this modifier should make sure that gestures (such as tap, longpress, magnification etc) should be able to co-exist…
iKK
  • 6,394
  • 10
  • 58
  • 131
1
vote
1 answer

Update image in UIImageView

I try to make UIKit element with replaceable image in it, that I can use like swiftUI element. I stuck at the moment, when image in UIImageView should be refreshed with imageInBlackBox from ObservableObject. I try'd to set new imageInBlackBox from…
Davagaz
  • 854
  • 1
  • 10
  • 23
1
vote
0 answers

Seconds on UIDatePicker (.countDownTimer)

How do I add a seconds column to the UIDatePicker? I am currently displaying this: With this UIViewRepresentable in SwiftUI struct DurationPicker: UIViewRepresentable { @Binding var duration: TimeInterval func makeUIView(context: Context)…
Matt Ward
  • 1,095
  • 1
  • 14
  • 28
1
vote
1 answer

Is it possible to detect PDFView notifications with Coordinator in UIViewRepresentable?

I'm having great difficulty working out how to implement a PDFView using UIViewRepresentable. I understand that I can get variables from SwiftUI -> UIKit via a simple Binding. I understand that I need to use a Coordinator to detect PDFView…
swift--help
  • 637
  • 5
  • 15
1
vote
0 answers

UIViewRepresentable for UITextField produces broken UI Behavior in SwiftUI

I have broken our production code down to the essentials. We wrote a UIViewRepresentable for the UITextField. To make the textfeild the first responder we defined IsEditing as a bindable value. We pass this value to the coordinator and update it…
Sebastian Boldt
  • 5,283
  • 9
  • 52
  • 64
1
vote
1 answer

Prevent updateUIView() from being called in UIRepresentableView?

I think I need to change a boolean in a UIRepresentableView before removing it from the ContentView but can't find a way, since I can't mutate the struct properties. Why do I need that? Because I need to prevent updateUIView() from being called one…
1
vote
0 answers

Why is UIViewRepresentable's makeUIView and updateUIView got called so many time xcode Playground?

I have a simple SwiftUI wrap with UIKit as display on Playground (using Xcode 12.1) import UIKit import PlaygroundSupport import SwiftUI struct ContentView: View { var body: some View { WrapView() } } struct WrapView:…
Elye
  • 53,639
  • 54
  • 212
  • 474
1
vote
1 answer

How to make CareKitUI Bar Charts compatible with SwiftUI

Currently, there is limited support for CareKit using SwiftUI. I understand, generally, the idea of making an object conforming to UIViewRepresentable, but am struggling to get going with how this would work in practice. The following is example…
GarethPrice
  • 1,072
  • 2
  • 14
  • 25
1
vote
3 answers

FirstResponder & :onCommit on TextField in SwiftUI

In a SwiftUI app, I need to set the focus on a TextField and bring the keyboard automatically, in standard Swift this would be done with: field.becomeFirstResponder() But this does not seem to exist in SwiftUI. I found a work around here. But, my…
Michel
  • 10,303
  • 17
  • 82
  • 179
1
vote
1 answer

How to observe loading progress for WKWebView in SwiftUI?

I'm building a web browser using SwiftUI and I broke the view into 3 parts: SearchView, WebView (UIViewRepresentable). In SearchView I have @Binding var query which gets updated on onCommit method of TextField. WebView has @Binding var query and…
Nikolai Prokofev
  • 184
  • 3
  • 14
1
vote
1 answer

UIViewRepresentable view not updating value

I am trying to create a custom SwiftUI View but I am getting problem in updating value through ObservedObject. import SwiftUI import Combine struct ContentView: View { @ObservedObject var model:InfoViewModel = InfoViewModel() var body: some…
Varun Naharia
  • 5,318
  • 10
  • 50
  • 84
1
vote
1 answer

SwiftUI can't bind class array parameter

In my SwiftUI project I have a button class model: import SwiftUI import Combine class Button: Identifiable, ObservableObject { var id = UUID() @Published var title = String() init(title: String) { self.title = title …
1
vote
0 answers

Unexpected visual behavior of SwiftUI Context Menu with UIViewRepresentable

UIViewRepresentable: import SwiftUI import MapKit import CoreData struct CustomView: UIViewRepresentable { var coordinate: CLLocationCoordinate2D func makeUIView(context: Context) -> MKMapView { MKMapView(frame: .zero) …
SVP
  • 2,773
  • 3
  • 11
  • 14