iOS: How do I "stick" UITextView on top of PDF control, so it can be scrolled with it?


How can I “stick” UITextView to document, so it can be scrolled with it? For now it is just overlaying the app and stays on top.
Maybe it’s a common task, but I’m pretty new to iOS :slight_smile:
Maybe I can put UITextView into annotation/widget somehow?


You can attach a text view as shown below. Note that I have set the content insets of the UITextView to zero, which may help with the padding you mentioned in your previous e-mail. I also put the text view inside of a UIScrollView which prevents iOS from scrolling the PDFViewCtrl when the UITextView because the first responder.

UITextView* tv = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, myRect.width, myRect.height)];

UIScrollView* sv = [[UIScrollView alloc] initWithFrame:myRect];

[tv setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];

[sv addSubview:tv];

[tv release];

[m_pdfViewCtrl->ContainerView addSubview:sv];

[sv release];

Regarding the coordinate questions from your previous e-mail, you have noticed correctly that the PDF coordinate space defines the origin at the bottom left of the page.