objective c - Major NSTextView Rotation Problems -
bear me on one, it's been frustrating me few days. seems should simple, reason keep running series of frustrating problems. i've done more work on ios in past, , never had these kinds of problems i'm having on os x. i'm wondering if i'm not understanding fundamental view architecture in appkit. in particular, not familar interaction between layer-backed views , plain views have not needed animate on os x before (and because ios makes views layer-backed default).
anyway, i'm having major problems trying rotate nstextview object 45 degrees. text labels placed in larger custom nsview subclass, of seems irrelevant specific problem. i'll go through i've tried , problems had. position of labels static, don't care whether or not animatable or not. labels need created , placed programmatically, not ib, size , position dependent on dynamically generated data. if matters, nstextviews using attributed strings.
1) first did way seemed straightforward me, set frames nstextview labels, added them subviews graph object, , called [labeltextview setframerotation:45] on them. worked on mountain lion, when tested on lion label height gets drawn on screen gets increased mysteriously (even though when log frame afterwards unchanged). isn't acceptable because need draw background color label looks readable when overlaid onto graph. on lion there bug or in setframerotation applied nstextview (or seem). know going on that? it's annoying works correctly on 10.8 not on 10.7. setframecenterrotation has same problem. making view layer-backed, or not, seems make no difference.
2) next tried using catransform3dmakerotation, after making parent view , nstextview layer-backed. used line labeltextview.layer.transform = catransform3dmakerotation(m_pi_4, 0, 0, 1.0);, text view doesn't rotate when this. test, tried same thing using plain nsview colored background, , rotate correctly. know possible reasons why wouldn't work nstextview?
3) tried enclosing nstextview in nsview container , calling setframerotation on that. rotate correctly, somehow triggers infinite recursion in core animation consumes gigabytes of ram unless kill process! again, ideas what's going on there?!?
4) tried of using autolayout position labels , positioning them manually setting frames. no differences in results either way.
5) using custom drawing, lot of work in particular case. i'd rather not support 10.7. try nstextfield see if suffers same thing in part 1), annoying because want of features of nstextview (this isn't single line blob of text).
what doing wrong here? never imagined simple being difficult working correctly on 10.7 + 10.8.
update: tried substituting nstextfield nstextview , problem in 3) goes away (the paragraph styling isn't how want yet, can possibly fix that). ideas on why nstextview has such problems being rotated nstextfield apparently doesn't? seems insane me. i'll try nstextfield without container next see if suffers drawing glitch on lion.
update 2: tried using nstextfield instead of nstextview , rotating it, , worked fine on both lion , mountain lion. visual glitch size of text view changes after rotation disappears. guess answer nstextview totally incapable of having frame rotated without triggering multiple bugs (especially on older versions of os x). if that's case, , nstextview isn't intended used way, apple's docs should so. can confirm that case?
Comments
Post a Comment