iphone - Logic of using UISlider Xcode -
i'm stuck @ moment controlling uislider in xcode. i've made horizontal slider in interface builder , manage code controls in xcode. right i'm not sure how code logic. if user slides nib left, i'd rotate image counter-clockwise , if user slides right, rotate image clockwise.
minimum value of slider i've set 0 , max 100. initial value 50.
for transformation i'm using cgaffinetransformmakerotation(myangle). i've set myangle float. condition, here's snippet of code:
myslider.value = myangle; // cgaffine if(myangle < 50) { myangle -= 0.1; } if(myangle > 50) { myangle += 0.1; }
when slide nib, rotates anti-clockwise. what's best logic can use? hope can help. thanks.
-hakimo
note doc says angle
as,
the angle, in radians, matrix rotates coordinate system axes. in ios, positive value specifies counterclockwise rotation , negative value specifies clockwise rotation. in mac os x, positive value specifies clockwise rotation , negative value specifies counterclockwise rotation.
i think following should work. not sure though. (considering minimumvalue 0).
float middlevalue = slider.maximumvalue / 2; float value = middlevalue - slider.value; float degrees = (middlevalue / 180) * value; float radians = degrees * (3.14/180);
Comments
Post a Comment