Skip to content

LayoutConstraints issue #126

Open
Open
@writing-shed

Description

@writing-shed

My app embeds an EditorView in a SwiftUI UIViewRepresentable struct which is the documented way to use UIKit views. The problem is that the text does not scroll when it reaches the bottom of the view. However, if I close the view and reopen it things wok as expected.

I have found that AutogrowingTextView.LayoutSubviews is only called once when the view opens, so isScrollEnabled is left set to false. Closing and reopening the view sorts this because there is sufficient text available.

The problem seems to be the layoutConstraints because the console contains the following immediately after EditorView.setup is called.

I can overcome the issue by setting isScrollEnabled after every keystroke.

2021-08-08 10:15:17.067778+0100 Easiwriter[3611:91422] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x60000243ae40 h=--& v=--& Proton.EditorView:0x7fb90d839800.height == 759.333 (active)>",
"<NSLayoutConstraint:0x60000240ecb0 V:|-(0)-[Proton.RichTextView:0x7fb90d0b4800] (active, names: '|':Proton.EditorView:0x7fb90d839800 )>",
"<NSLayoutConstraint:0x60000240eb70 Proton.RichTextView:0x7fb90d0b4800.bottom == Proton.EditorView:0x7fb90d839800.bottom (active)>",
"<NSLayoutConstraint:0x600002409ae0 Proton.RichTextView:0x7fb90d0b4800.height >= 926 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002409ae0 Proton.RichTextView:0x7fb90d0b4800.height >= 926 (active)>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions