Posts

Post not yet marked as solved
4 Replies
2.0k Views
There's a nasty SwiftUI bug in which a TextField disappears if placed in a HStack within a List.List { ForEach(0...200, id: \.self) { index in HStack { Text("Text \(index)") TextField("Test", text: .constant("TextField \(index)")) } }}- Screenshot: https://i.stack.imgur.com/HARDF.png- Video: https://recordit.co/X12uGct7gDThis happens when TextField is placed within a HStack / VStack / ZStack / .overlay() / .background(). It does not happen when TextField is the only child of ForEach. I have filed a bug (FB7500885) but I'm looking for ideas from the community to work around it. Here is what I've tried so far:Setting an explicit .frame() on TextFieldSetting .fixedSized() on TextFieldUsing a UITextField wrapped in a UIViewConvertible, with or without layout constraintsIs there anything else I could try?
Posted
by ldidi.
Last updated
.
Post not yet marked as solved
5 Replies
7.7k Views
I would like to present an action sheet on iPad using SwiftUI, but it crashes with the following error:Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet from _TtGC11AppAlpha17HostingControllerVS_11ContentView_ (<_TtGC11AppAlpha17HostingControllerVS_11ContentView_: 0x105702dc0>). The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'My code:.actionSheet(isPresented: $isShowingActionSheet) { ActionSheet( title: Text("Add a photo"), message: Text("Please select a source"), buttons: [ .cancel { }, .default(Text("Photo from library")) { self.imageSource = .photoLibrary self.isShowingImagePicker.toggle() }, .default(Text("Take a picture")) { self.imageSource = .camera self.isShowingImagePicker.toggle() } ] ) }I understand that I have to pass a source view for the action sheet to layout properly, but I don't have access to the underlying UIKit element. How should it be done?Target: iPadXcode 11.2 beta 2 (11B44)
Posted
by ldidi.
Last updated
.