Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView after CATransform3D: scrolling all out of whack

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.

like image 929
DanM Avatar asked May 27 '15 02:05

DanM


1 Answers

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?

like image 55
Rory McKinnel Avatar answered Nov 11 '22 14:11

Rory McKinnel