Questions tagged [uiviewrepresentable]

229 questions
1
vote
2 answers

UIViewRepresentable view disappears when contextMenu is activated

I'm trying use context menu with UIViewRepresentable. When context menu is activated, UIViewRepresentable disappears. Here is the code: UIViewRepresentable view: struct TestView: UIViewRepresentable { func makeUIView(context: Context) -> some…
1
vote
1 answer

SwiftUI, can't change state from within delegate callback? (code attached)

Anyone able to spot why when I set the "firstPass" state variable in the "updateUIView" callback it does NOT set the state? As output I see: First Pass1: true First Pass2: true. // <= not set to false as expected Also I do not in Xcode where I…
Greg
  • 34,042
  • 79
  • 253
  • 454
1
vote
1 answer

CGAffineTransform scale resize not working properly when used in SwiftUI

I tried to use the custom view button I created from UIKit to SwiftUI view using UIViewRepresentable but it did not work as expected. Expected: The view button will shrink upon tap or hold. Actual: The view button expands when tap initially then…
1
vote
1 answer

How can i access ViewController Class from Coordinator?

I am using a UIViewControllerRepresentable Class in my SwiftUI like this: struct CalendarDayView: UIViewControllerRepresentable { func makeCoordinator() -> Coordinator { return Coordinator(self) } func makeUIViewController(context:…
Niklas
  • 1,638
  • 4
  • 19
  • 48
1
vote
1 answer

UITextView avoid text selection, but keep tappable links

I have a pop-up window, that shows terms of service & privacy policy for users, how to disable text selection but keep links tappable. screenshot If I set: SOLVED: By adding textViewDidChangeSelection method in UIViewDelegate and…
user16253584
1
vote
0 answers

SwiftUI wrapping UITableViewCell into UIViewRepresentable

When I have UITableViewCell examples class MyTableViewCell: UITableViewCell { ... } that is self-sizing table view cell i.e. has constraints attached to all edges and then wrap this cell into SwiftUI UIViewRepresentable in order to use it in…
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
1
vote
2 answers

Update inputAccessoryView in SwiftUI (UIViewRepresentable)

I want to display search results above the keyboard with SwiftUI. For this, I made a UIViewRepresentable for UITextField and set the inputAccessoryView accordingly. Everything is displayed correctly, but the inputAccessoryView is not updating. …
fer0n
  • 295
  • 1
  • 5
  • 14
1
vote
1 answer

Custom TextField keyboard in SwiftUI with UIViewRepresentable

I'm using a custom UITextField inside a UIViewRepresentable, to have a Textfield with only a decimalpad and a custom keyboard toolbar. The goal is to add to the toolbar basic things such as inserting a minus, an E, etc... I've seen a lot of code…
1
vote
1 answer

SwiftUI ObservedObject is re-initiated everytime

I have a simple class to store some data in my SwiftUI app: final class UserData: ObservableObject { @Published var id = 1 @Published var name = "Name" @Published var description = "Initial text" } I also defined it as…
1
vote
0 answers

SwiftUI - Material Components , TextFields

I want to use mdc components in my SwiftUI app. I created a class with protocol UIViewRepresentable, but I would like to modify the height to some constant or maybe remove inner padding. func makeUIView(context: Context) -> MDCOutlinedTextField { …
1
vote
1 answer

SwiftUI changing state that appears in action sheet

I have a simple SwiftUI example that isn't behaving as expected. What I expect to happen: When the button is clicked, the sheet should show a random number (text). What happens instead: The first time, the sheet shows foo. In subsequent times, a…
jaynp
  • 3,275
  • 4
  • 30
  • 43
1
vote
1 answer

How to update page indicator in SwiftUI?

Interface: SwiftUI Life Cycle: SwiftUI Language: Swift Xcode version: 12.5 I want to use a page indicator in the custom carousel view with core data. The indicator works fine with the current code below, but if a page is added or deleted from Core…
1
vote
0 answers

Issues with STPAuthenticationContext in UIViewRepresentable

I am trying to implement Stripe on SwiftUI. After the user registers, I would like them to add a payment method to their account without making an actual payment. I have successfully created the STPPaymentCardTextField using a UIViewRepresentable.…
devOP1
  • 295
  • 3
  • 13
1
vote
0 answers

Trying to implement the ability to launch multiple wkwebview instances to emulate tabbing on a browser

I'm trying to make a very barebones mobile browser to practice swiftui and wkwebview (WKwebview is wrapped in a UIViewRepresentable). However, when trying to implement multiple tabs for the browser I hit an odd error. The default webview works but…
1
vote
1 answer

How to query UITextField wrapped in UIViewRepresentable from a Xcode UI test?

I'm developing my app with SwiftUI, but some elements are still from the UIKit world, e.g. one UITextField with special behavior, that's why I use a UIViewRepresentable where the makeUIView methods returns a UITextField. When I try to enter text via…
swalkner
  • 16,679
  • 31
  • 123
  • 210