WSTagsField
WSTagsField copied to clipboard
SwiftUI app crash on invalidateIntrinsicContentSize()
Which version of the WSTagsField are you using?
SPM 5.4.0
On which platform does the issue happen?
iOS 14.5
Are you using Carthage?
No
Are you using Cocoapods?
No
Which version of Xcode are you using?
Version 12.5.1 (12E507)
What did you do?
I created WSTagsField as UIViewRepresentable in its simplest form and put it in the Form in Section shown by .fullscreenCover() from the parent view.
struct HashtagsTextField: UIViewRepresentable {
private enum Constants {
static let layoutMargins = UIEdgeInsets(top: 2, left: 6, bottom: 2, right: 6)
static let contentInstet = UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 16)
static let spaceBetweenLines: CGFloat = 5.0
static let spaceBetweenTags: CGFloat = 10.0
}
// MARK: - Stored Properties
@Binding private(set) var text: String
let placeholder: String
private let tagsField = WSTagsField()
// MARK: - Methods
func makeUIView(context: Context) -> WSTagsField {
tagsField.layoutMargins = Constants.layoutMargins
tagsField.contentInset = Constants.contentInstet
tagsField.spaceBetweenLines = Constants.spaceBetweenLines
tagsField.spaceBetweenTags = Constants.spaceBetweenTags
tagsField.font = .systemFont(ofSize: 17.0)
tagsField.backgroundColor = .clear
tagsField.tintColor = UIColor(named: "darkBrown")
tagsField.textColor = .white
tagsField.selectedColor = UIColor(named: "darkBrown")
tagsField.selectedTextColor = .white
tagsField.isDelimiterVisible = true
tagsField.placeholderColor = UIColor(named: "text")
tagsField.placeholderAlwaysVisible = false
tagsField.acceptTagOption = .space
tagsField.shouldTokenizeAfterResigningFirstResponder = true
return tagsField
}
func updateUIView(_ uiView: WSTagsField, context: Context) {
uiView.text = text
}
}
What did you expect to happen?
App doesn't crash when fullScreenCover disappears (maybe it's time to make SwiftUI version of this field?).
What happened instead?
When WSTagsField (as UIViewRepresentable) is in the Section in Form as the content of the .fullScreenCover() and the view disappears (via presentationMode environment), the app crashes every time.