Question

I've scoured through several questions asking about how to prevent scrolling when selecting a first responder however nothing I find seems to work for this issue.

I have a UITextField above my table view at the very top of my page. When the user selects it (or when I do it programmatically) it drops down a bit, seemingly giving room for options such as "paste" or autocorrect (which I've disabled). I'd like to prevent this from happening.

I've tried setting the scroll position myself, which it initially does, but then it instantly jumps down a bit. Is there a way I can make the paste/edit bubble appear below the textfield (like it does with textfields in the header)? I'm thinking perhaps that will prevent it from jumping downwards, but I can't find information on this.

I'm completely stuck so any help is appreciated. Links, vague suggestions, whatever. Thank you.

Was it helpful?

Solution

Try embedding your text field in a scroll view the same size as your text field.

The reason why this should work is because when a text field becomes first responder, it only scrolls the scroll view that is its most recent ancestor in the view hierarchy. If it only finds the dummy scroll view, whose content size should not exceed its bounds size, then no scrolling should occur in either scroll view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top