Questions tagged [uiviewrepresentable]

229 questions
2
votes
2 answers

SwiftUI MapKit UIViewRepresentable Can't present Alert

I have a SwiftUI app where a couple of views are MapKit maps made with UIViewRepresentable. I have custom annotations for the points of interest and use both the right and left callout buttons for further action. On the right I simply want to…
JohnSF
  • 3,736
  • 3
  • 36
  • 72
2
votes
2 answers

Changing state in onAppear breaks PageViewController

I'm struggling to understand why a PageViewController does not work as expected when there is a change to a @Published EnvironmentObject variable during .onAppear in its parent View. If I comment out the .onAppear modifier in DetailView, then…
2
votes
0 answers

Height issue with Attributed String in swiftUI

Attributed View is not updating layout correctly for attributed string. Below is my code. I have created Attributed Label for SwiftUI. import SwiftUI class ViewLabel : UIView { private var label = UILabel() override init(frame: CGRect)…
Dattatray Deokar
  • 1,923
  • 2
  • 21
  • 31
2
votes
1 answer

How could I use PocketSVG to display the entire SVG image in the SwiftUI?

My source code is very simple as follow: // // SVGImage.swift // WorldRoad // // Created by norains on 2019/11/26. // Copyright © 2019 norains. All rights reserved. // import PocketSVG import SwiftUI struct SVGImage: UIViewRepresentable { …
norains
  • 743
  • 1
  • 5
  • 12
2
votes
2 answers

How can I get SKEmitterNode to work in SwiftUI?

I'm trying to update the colour of an SKEmitterNode within a UIViewRepresentable. The hue value is passed in from the state on the parent View, and the emitter colour should update when the hue value in the parent state updates. It initially…
codewithfeeling
  • 6,236
  • 6
  • 41
  • 53
1
vote
1 answer

SwiftUI hyperLink with UIViewRepresentable

I am trying to create HyperLink with UITextView in UIViewRepresentable but I can't see any text in UITextView. Using: ArtieHyperLink(url: "https://www.google.com.tr", text: "This is HyperLink test.", hyperText: "test") UIViewRepresentable: struct…
Ufuk Köşker
  • 1,288
  • 8
  • 29
1
vote
2 answers

Swiftui UIViewRepresentable - How to update PKCanvasView image when imageData source is changed on user action

I am creating a SwiftUI app with PencilKit & UIViewRepresentable. I am adding a image coming from server on top of the PKCanvasView. Code works fine when I click on a image and open a canvas view then close it and reopen it. But I am not able load a…
1
vote
1 answer

Binding array is empty when accessed through Coordinator

I am having an issue with my Coordinator. I am interacting with a MKMapView via SwiftUI. I am passing in a Binding to the UIViewRepresentable and need to access that same Binding in the Coordinator. Inside the Coordinator I determine what…
Obito
  • 79
  • 9
1
vote
1 answer

Setting up .onCommit{} in UITextFieldViewRepresentable SwiftUI

I bridge UIKit with SwiftUI as follows: struct UITextFieldViewRepresentable: UIViewRepresentable { @Binding var language: String @Binding var text: String init(language: Binding, text: Binding) { self._language…
Tirna
  • 383
  • 1
  • 12
1
vote
1 answer

How do I make a UITextView inside of a UIViewRepresentable update when I add an attribute to an NSMutableAttributedString?

I am trying to make a WYSIWYG editor by interfacing between SwiftUI and UIKit via a UIViewRepresentable. I am primarily using SwiftUI but am using UIKit here as it seems SwiftUI does not currently support the functionality needed. My problem is,…
1
vote
1 answer

UIViewRepresentable and Map SwiftUI

I am using UIKit MKMapView in SwiftUI to have more functionality. I pass the map region to the UIViewRepresentable via Binding, so I can update the UIKit view from the SwiftUI view that uses that MKMapView. The issue is that I have a button on top…
Nathace
  • 454
  • 3
  • 10
1
vote
0 answers

Multitouch UITouches after SwiftUI Drag

I'm implementing a SwiftUI control over a UIView's drawing surface. Often you are doing both at the same time. Problem is that starting with the SwiftUI control will block the UIKit's UITouch(s). And yet, it works when you start with the UITouch…
Warren Stringer
  • 1,692
  • 1
  • 17
  • 14
1
vote
1 answer

Type 'VideoView' does not conform to protocol 'UIViewRepresentable'

I'm trying to embed a YouTube video into my app and keep getting this error Type 'VideoView' does not conform to protocol 'UIViewRepresentable' here's my code: import SwiftUI import WebKit struct VideoView: UIViewRepresentable { let…
Ash
  • 81
  • 9
1
vote
1 answer

Can't Turn UIKit Into Swift UI With UIViewRepresentable

I have followed two tutorials on UIViewRepresentable and thought the following would work, yet it didn't and I think my situation is more complex than in the tutorials. Hello, I am trying to turn this code import SpriteKit import…
sivafe9540
  • 23
  • 7
1
vote
1 answer

Using UIViewRepresentable to wrap MarqueeLabel view

I have a simple UIViewRepresentable of a MarqueeLabel, but it does not work. My guess is that the frame is not correctly set, but I don't know what to pass to the MarqueeLabel initialiser as a frame. Using geometry Reader or some other way to get…
D. Kee
  • 169
  • 14