Can I override scroll view's automatic behavior to scroll to the first responder?

I didn't test this particular situation, but I've managed to prevent a scrollview from bouncing at the top and bottom by subclassing the scrollview and overriding setContentOffset: and setContentOffset:animated:. The scrollview calls this at every scroll movement, so I'm fairly certain they will be called when scrolling to the textfield You can use the delegate method textFieldDidBeginEditing: to determine when the scroll is allowed In code: (void)textFieldDidBeginEditing:(UITextField *)textField { self. BlockingTextViewScroll = YES; } -(void)setContentOffset:(CGPoint)contentOffset { if(self.

BlockingTextViewScroll) { self. BlockingTextViewScroll = NO; } else { super setContentOffset:contentOffset; } } -(void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated { if(self. BlockingTextViewScroll) { self.

BlockingTextViewScroll = NO; } else { super setContentOffset:contentOffset animated:animated; } } If your current scroll behaviour works with a setContentOffset: override, just place it inside the else blocks (or preferably, in a method you call from the else blocks).

I didn't test this particular situation, but I've managed to prevent a scrollview from bouncing at the top and bottom by subclassing the scrollview and overriding setContentOffset: and setContentOffset:animated:. The scrollview calls this at every scroll movement, so I'm fairly certain they will be called when scrolling to the textfield. You can use the delegate method textFieldDidBeginEditing: to determine when the scroll is allowed.In code: - (void)textFieldDidBeginEditing:(UITextField *)textField { self.

BlockingTextViewScroll = YES; } -(void)setContentOffset:(CGPoint)contentOffset { if(self. BlockingTextViewScroll) { self. BlockingTextViewScroll = NO; } else { super setContentOffset:contentOffset; } } -(void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated { if(self.

BlockingTextViewScroll) { self. BlockingTextViewScroll = NO; } else { super setContentOffset:contentOffset animated:animated; } } If your current scroll behaviour works with a setContentOffset: override, just place it inside the else blocks (or preferably, in a method you call from the else blocks).

This may turn out to be useless, but have you tried setting scrollView. UserInteractionEnabled to NO before calling scrollrectToVisible: & then setting it back to YES? It may prevent the automatic scrolling behavior.

Nope. For thoroughness I tried every combination of disabling userInteractionEnabled on both the scroll view and the UITextField, and placing those calls before and after scrollRectToVisible or becomeFirstResponder, or before and after both. Disabling userInteractionEnabled on the UITextField generally made the keyboard not appear, even if it was enabled when I called becomeFirstResponder.

Setting it on the scroll view didn't seem to have any effect. – morningstar Oct 12 at 1:23.

Try changing the view autoresizing to UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin. The default is FlexibleTopMargin so maybe thats the reason. Btw scrollRectToVisible: is using the scrollView.contentSize.

The other thing you can try to change the scrollView size first and then apply the scrollRectToVisible: change. First frame change, then content change. (Maybe observe the keyboard did appear event).

I'm probably not gonna go there. I had to set all the autoresizing masks to very specific settings to get all the scroll, zoom, and tilt to work. "The other thing you can try to change the scrollView size first and then apply the scrollRectToVisible: change."

Did that. – morningstar Oct 12 at 18:03 yes I meant the scrollView resizing – iPortable Oct 12 at 18:09 Ok, tried that, no difference. – morningstar Oct 12 at 23:14 If you know something about autoresizing maybe you can see my other question.

– morningstar Oct 120 at 8:08.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions