Post

Replies

Boosts

Views

Activity

UIViewRepresentable of UITextView in SwiftUI layout issues
I'm trying to show a list with UITextView in the cells to display text the user can select. The text gets clipped, and if I specify "isScrollEnabled = false" then the text no longer wraps.Here's a simple version of my code:struct UITextViewContainer: UIViewRepresentable { let text: String func makeUIView(context: UIViewRepresentableContext<Self>) -> UITextView { let view = UITextView() view.isScrollEnabled = false view.isEditable = false return view } func updateUIView(_ uiView: UITextView, context: UIViewRepresentableContext<Self>) { uiView.text = self.text } } struct ContentView : View { var body: some View { List(1...5) { item in UITextViewContainer(text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur quis pharetra diam, rhoncus tristique orci. Nam semper interdum facilisis. Sed mollis ligula ac odio iaculis iaculis. Ut consectetur bibendum augue, at rutrum metus semper ut. Nam molestie, arcu sed commodo facilisis, erat sem consectetur sem, a mattis nisi libero cursus sapien.") } } }With isScrollEnabled = trueWith isScrollEnabled = false
5
0
7k
Jun ’19