Search code examples
iosuiscrollviewuikituitextviewtextkit

Multiple UITextView inside UIScrollView in paging mode interaction problem


I am creating multiple UITextViews inside UIScrollView in paging mode based on textContainer. View structure

All works as expected, but I want to make textView selectable. So of course I make it [textView setSelectable:YES]; while adding on scrollview . ScrollView canCancelContentTouches and delaysContentTouches are set to NO and underlying textView receives touches, as I can see by overriding (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event . But textView still do not become selectable, and when I log vars inside textViews it shows that isSelectable and isEditable are set to NO, no matter if I made them YES while adding as subview of scrollView. Also bounds of textView are not bigger than containing scrollView . If I am adding UIButton as subview of textView it also receives touches . If only one textView is added selection and edit is working just fine. Does anyone have any idea what can be wrong and why touches are delivering but text events are not triggering? Or is it expected behavior?


Solution

  • It seems, when there is one textStorage for multiple UITextViews, even if each with it's own container, it becomes static and there is nothing you can do with that . Similar problem and answer with reference to iOS 7 Programming Pushing the Limits book: https://stackoverflow.com/a/41842189/12701117

    I will leave question and answer for indexing reasons.