I have a weird problem using a popover - this behavior is pretty random to me so I somehow think it's a bug - but I cannot reproduce the problem in a smaller project to give you reproducible code.
I'm showing a table with a few rows and columns, one of this items per row is editable. If the user taps on the button a popover
does appear, presenting a View
with a TextField
or a TextEditor
(tried both with the same result).
It all works fine on the iPhone (any situation), it works on the iPad in horizontal format, it works on the iPad in vertical format if there is an external keyboard connected. But - as soon as iOS needs to show the on screen keyboard, the popover
disappears and so does the keyboard again.
I replaced the popover view with a simplified version, to make sure there is nothing wrong with the popoverView
and still got the same behavior.
struct SimpleRemarkPopover: View {
@Binding var showPopover:Bool
@State var comment:String
var body: some View {
TextEditor(text: $comment)
Button(action: {
showPopover = false
}, label: {
Text("Hide Popover")
})
}
}
The Button showing the popover is also not too complex, nothing special there:
Button(action: {
showPopover = true
}, label: {
Image(systemName: "square.and.pencil")
})
.popover(isPresented: $showPopover) {
SimpleRemarkPopover(showPopover: $showPopover, comment: item.comment ?? "")
}
Except a ScrollView
, as ScrollViewReader
and a GeometryReader
there are no other Elements used except ZStack,
HStack
and VStack
- so actually nothing fancy.
All data to fill the table comes from a ObservableObject
Did anyone experience similar problems, any known bugs or workarounds for this problem? For a few days I'm trying to get the same result on my test-project, but can't - which is pretty annoying.