Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI app crash on invalidateIntrinsicContentSize() #159

Open
tryboxx opened this issue Sep 4, 2021 · 0 comments
Open

SwiftUI app crash on invalidateIntrinsicContentSize() #159

tryboxx opened this issue Sep 4, 2021 · 0 comments

Comments

@tryboxx
Copy link

tryboxx commented Sep 4, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant