9

So I have a UITextView, and in viewDidLoad I rotate its layer so it appears to be slanted back into the screen (sort of like the Star Wars opening crawl).

The problem is that scrolling is all messed up. Dragging up will scroll for a bit, then jump backward or similar; on the simulator it will even crash sometimes with an error about a coordinate containing NaN.

Similarly, when I try to automatically scroll the UITextView via [UIView animateWithDuration:...] I also get unexpected skips, jerks, etc.

I assume this has something to do with the fact that I've manipulated the layer, but the touch events as well as the animations are registered on the view... Or something like that?

Anyway, I'm pretty stumped.

DanM
  • 6,727
  • 11
  • 48
  • 83
  • Did you try to apply transformation to the superview instead? – Lukasz May 30 '15 at 10:51
  • Are you using constraints to position the text view? There seem to be issues with using transformations and constraints together. A common workaround seems to be to wrap the offending item in another view. The big issues are on iOS7, but some applies to iOS8 as well. This link discusses the issues which may be your issue: http://stackoverflow.com/questions/12943107/how-do-i-adjust-the-anchor-point-of-a-calayer-when-auto-layout-is-being-used – Rory McKinnel Jun 01 '15 at 11:53
  • @RoryMcKinnel no, I'm just using springs & struts. But regardless, wrapping the UITextView in another view does seem to have helped. If you want to put that in an answer, I'll mark it correct. – DanM Jun 01 '15 at 12:12
  • Should clarify: animatewithduration doesn't work regardless.... But setting up a timer and animating the content offset manually seems to. – DanM Jun 01 '15 at 12:13
  • @DanM Glad it helped. I've just gone through similar pain. Added as an answer. – Rory McKinnel Jun 01 '15 at 12:14

1 Answers1

3

Are you using constraints to position the text view? There seem to be issues with using transformations and constraints together. A common workaround seems to be to wrap the offending item in another view. The big issues are on iOS7, but some applies to iOS8 as well. This link discusses the issues which may be your issue:

How do I adjust the anchor point of a CALayer, when Auto Layout is being used?

Community
  • 1
  • 1
Rory McKinnel
  • 7,730
  • 2
  • 15
  • 28