Questions tagged [uiviewrepresentable]
229 questions
0
votes
1 answer
Send data changes from UIKit, Wrapped inside UIViewRepresentable, to SwiftUI, and Rich Text Editor problem
I am working on a SwiftUI project, the functionalities it required is to make a Rich Text Editor on IOS.
The approach I am following is fairly simple, I used cbess/RichTextEditor link originally written in UIKit and import it into SwiftUI. To run…

Hoàng Sơn
- 33
- 3
0
votes
0 answers
UIViewRepresentable updateUIView() strange behaviour when using .sheet()
I just found some strange behaviour of SwiftUI's UIViewRepresentable. I'm not sure if this is a bug, or my mistake in understanding SwiftUI.
I've made small reproduction to show the problem.
I created UIViewRepresentable for MKMapView:
import…

Maksymilian Tomczyk
- 1,100
- 8
- 16
0
votes
0 answers
Toolbar accessory added to UITextView as a UIViewRepresentable only displays after first launch of iMessage extension application
Would like to have the toolbar show all the time.
Any help is greatly appreciated as this is a real drag for the user experience.
I've added a toolbar to the keyboard for the TextView as shown below.
However the toolbar only shows after the app has…

ekd
- 26
- 4
0
votes
1 answer
Adding placeholder to UITextView in SwiftUI (UIViewRepresentable)
I am trying to add a placeholder to my textViews made with SwiftUI, but when doing textView.text = placeholder or textView.text = "", nothing happens...
Using textView.insertText(placeholder) works, but then I am unsure on how to remove the…

adam.code
- 73
- 9
0
votes
1 answer
TextView UIViewRepresentable resets UndoManager when lineSpacing added via attributedText value change
I am using a TextView UIViewRepresentable as outlined here https://www.appcoda.com/swiftui-textview-uiviewrepresentable/.
It’s working as expected, apart from one issue concerning line spacing. SwiftUI’s lineSpacing modifier seems to have no effect…

Barrrdi
- 902
- 13
- 33
0
votes
1 answer
PDFKit .go(to: ) Method in SwiftUI
hello i want to display a PDF file at page 7 in my SwiftUI app.
I would also like to use the functions .go(to :) and .currentPage() outside the UIViewRepresentable.
import SwiftUI
import PDFKit
struct PDFKitView: View {
var pdf: PDF
var body: some…

Carl
- 1
- 2
0
votes
0 answers
UICollectionViewCell with Binding Variable for SwiftUI?
So I'm building a project based on SwiftUI and on one of my struct Views I have a UIViewRepresentable that produces a UICollectionView. Also on this View, I have a @State variable called 'showNextSheet' that presents a new sheet when toggled.
I've…

nicksarno
- 3,850
- 1
- 13
- 33
0
votes
1 answer
Intrinsic height for wrapped non scrolling UITextView in SwiftUI ScrollView
I'm working with a wrapped UITextView via UIViewRepresentable. This textView is supposed to be as high es required, based on its content, i.e. the (attributed)string.
struct TextView: UIViewRepresentable {
@Binding var text: String
func…

benrudhart
- 1,406
- 2
- 13
- 25
0
votes
1 answer
UITextView Delayed AttributedString Link SwiftUI
I have a Text view thal look like this:
class StudyText: UITextView, UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
…

Kevin
- 1,103
- 10
- 33
0
votes
1 answer
SwiftUI: Overlap between views in VStack
I learned to create this HTMLStringView to show html strings in my app:
struct HTMLStringView: UIViewRepresentable {
let htmlContent: String
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func…

Charlotte L.
- 143
- 3
- 13
0
votes
0 answers
UICollectionView will not register long press without delay
I am using a UICollectionView within a UIViewRepresentable on an app. I am trying to register a long press gesture on the UICollectionView with a minimum press duration at or very close to 0, but the press keeps on waiting for about 0.5 seconds…

JohnOfIreland
- 271
- 2
- 11
0
votes
2 answers
SwiftUI How to update State property when if was updated from sheet view
I Have a textfield where you can enter name and a button to choose from contacts, but as I choose from contacts the textfield doesn't update and looks empty (and saves empty result), but as I press the button once more it updates the textfield, how…

Roman R
- 39
- 8
0
votes
2 answers
SwiftUI how to create List with custom UIViews inside it
I consider how to create SwitUI List that has as its row custom UIViews.
I create List:
List {
RowView()
}
RowView is UIViewRepresentable of UIRowView
struct RowView : UIViewRepresentable {
func makeUIView() -> UIRowView { ...…

Michał Ziobro
- 10,759
- 11
- 88
- 143
0
votes
1 answer
Chain methods with UIViewRepresentable subclass
I'm trying to implement a UITextView using the following UIViewRepresentable
import Foundation
import SwiftUI
struct TextView: UIViewRepresentable {
@Binding var text: String
var _editable : Bool = true
func makeUIView(context:…

Yann Bizeul
- 403
- 3
- 10
0
votes
1 answer
Trying to assign to an @EnvironmentObject from a child view to a parent fails as EnvironmentObject is read-only
I have a map based app so I want to have an app-wide property for the current position of the map.
I'm initializing it in SceneDelegate
let currentPosition = CurrentPosition()
let mainView = MainView(appState: AppState(),…

trusk
- 1,634
- 2
- 18
- 32