iOS: Stop ScrollView from making room when selecting textfield at top - ios

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.

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.

Related

Add refreshControl to a scrollView with pageControl

As it can be seen in the gif from the link, I was able to add the refresh control to the scrollView but it is only shown for the first page. It still works for the other pages but it is not showing the refresh indicator which might be confusing for the user.
I have tried already a couple of ideas but nothing seems to work.
I am looking for a solution, which either only makes it possible to use the refresh control on the first page and disables vertical scrolling for the other pages or a solution which shows the refresh indicator at every page.
I would also like to disable the diagonal dragging. I added this in case there is a solution which solves both problems.
https://giphy.com/gifs/KfqJnVlwKE9fwFc07R/html5
Help will be very appreciated.
The indicator looks like it is probably added as a child of the scrollview, meaning it is scrolled along with the other contained views, and hence scrolled off-screen.
For an element you want to always be displayed over the scroll view add the indicator as a sibling of the scroll view (i.e. a subview of the scroll view's parent).

UITextView on Catalyst with Long text, invisible text ranges when scrolling

I have an issue with Catalyst. I'm trying to display a long text in a UITextView, and on iOS everything works well, no issues.
On Mac (with Catalyst) however, when I scroll the textview, some parts disappear. Does anyone have an idea on how to fix this?
I have tried calling setNeedsLayout/Display/layoutIfNeeded on the textview when scrolling but no luck. The only thing that "worked" is to remove the textview from the view hierarchy and readd it to the container view on scroll finished. Still not ideal, as you lose selection when you want to select some text and scroll. (When I save the selection and re-apply it, then the blue highlight is invisible)
Using a UILabel in a scrollview could work, but then you lose all user interactions (no editing/selecting text)
Does anyone have any idea on how to fix this? Or I should just wait for Apple to fix this.
See the video/gif of the original issue:

How to move my chat input bar up on top with keyboard in Xcode?

I create a chat program. I've created my chat sequence using TableView. Now I have a view on the bottom of the page, contains one TextField and a send button. Now if I press on the TextField, the keyboard appears. I need to:
reduce the height of the tableView so that I still can see the most recent chat message, and return it to its former height if the keyboard is hidden.
move the view up to sit on top of the keyboard, and return it to its former position if the keyboard is hidden.
do both of things above with animation.
I'm still newbie in this keyboard + animation area. I only know I will need to implement textFieldDidBeginEditing and textFieldDidEndEditing to do this. But I don't know what code I should implement inside it. This answer provided some, but not the exact answer to my problem (it only moves the floating TextField in the scrollable view of TableView to be within the visible area, not moving a view not related with TableView). Any help or even article will be appreciated. Thanks!

UITableView setContentOffset: called from main loop?

I have a UITableView with a variable size UITextView and when the user is about to enter text I move the text field up so it is visible above the keyboard. All is good. But when I adjust the contentOffset while the user is typing it works fine too, but a moment later the table view automatically scrolls back to the top, hiding the text view behind the keyboard. As it turns out, setContentOffset is for some reason called from the main loop with the initial value again. This is really ruining my day, it works all fine and then the system seems to decide to mess up my work again deliberately.
Why is this so? How can I prevent this?
Here is a screenshot of the stack trace:

NSTextView stops being able to scroll once new text is set

I have a TextView made in the Interface Builder;
It scrolls fine with its default text, but as soon as I programatically set the text to something else, it no longer scrolls.
I do not disable scrolling, and I have tried enabling scrolling (setScrollEnabled:YES), and user interaction (setUserInteractionEnabled:YES) both of which make no difference.
The things that I have found:
It scrolls with the default text showing
It doesn't seem to matter what text I set in it, it just stops scrolling as soon as it is set. I'm doing it programatically like this:
self.myTextView.text = #"any text"; (or [self.myTextView setText:#"any text"]; has the same effect.)
I have two other Textfield in the same View, one of which is using the View Controller as its delegate. The TextField in question is not using the View Controller as its delegate. None of the delegate methods set anything to do with scrolling.
Both of the other TextViews have their scrolling capability set to defaults. If I change the one that doesn't need it to no scrolling, it makes no difference to the problem.
The one that has the View Controller as its delegate continues to scroll after I edit it (non programatically) and this one continues to be able to scroll once the one in question freezes.
If I delete these two other TextFields, then the one in question works as expected, i.e. it scrolls after adding text.
Any thoughts?
Thanks.
Make sure your new text is long enough to be able to get scroll.
if text is just one line it wont scroll but if its larger then text area size then it will scroll its by default settings

Resources