问题
It's possible to put a button inside a scroll view and make it scroll together with the view?
I try to explain the issue. I have a scrollView containing a textView showing some text. In the text there's a link and i have a button, put beside this link that, when pressed, open the link in safari. Now, the text is longer than the textView, so i had to put the Text view inside a Scroll View to make it scroll. I tried putting the button inside the scrollView as well, but when i scroll, only the text get scrolled and the button stays still where it is, when instead i want the button to scroll together with the text, to have it evere beside the link that is in the text. Is is possible?
回答1:
As far as I'm aware, you can't put controls inside a UITextView
.
You could implement your desired behaviour by moving the button during the textView's - (void)scrollViewDidScroll:(UIScrollView *)scrollView delegate method.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// Move button according to scroll position, using scrollView.contentOffset
}
来源:https://stackoverflow.com/questions/15270377/how-to-make-a-button-scroll-inside-a-uiscrollview