Currently i am using following code to rotate my image
- (void)myImageRotate:(UIRotationGestureRecognizer *)gesture
{
if(arr==nil)
{
arr=[[NSMutableArray alloc] init ];
}
if ([gesture state] == UIGestureRecognizerStateBegan || [gesture state] == UIGestureRecognizerStateChanged)
{
currentRotation =(float) [gesture rotation];
self.transform=CGAffineTransformRotate(self.transform,currentRotation);
[gesture setRotation:0];
[arr addObject:[NSNumber numberWithFloat:currentRotation]];
}
NSLog(@"Rotation Value: %f", currentRotation);
• 将所有轮换价值节省到一个阵列和营地;进行反射阵列和计算/最后的轮调价值
NSArray *reversedArray = [[arr reverseObjectEnumerator] allObjects];
NSLog(@"Array: %@", arr);
NSLog(@"Reversed Array: %@", reversedArray);
//Now the Reversed array is displaying always start with 0.0.....like value whatever may be the rotation Reversed Array: ( 0, 0, "0.001174212", "0.006030798", "0.01210225", "0.01215386", "0.01220191", "0.01224673", "0.006139159", "0.006149054", "0.01850212", "0.01237607", )
lastRotationValue = 0.0;
for (NSString* stringValue in [arr reverseObjectEnumerator]) {
double value = [stringValue doubleValue];
if (value != 0.0) {
//Note: 1 degree=0.0174532925 radian
lastRotationValue = value;
break;
}
}
if (lastRotationValue != 0.0) {
NSLog(@"My firstNonZeroValue of Rotation Degree:%f",lastRotationValue);
}
}
现在,我写上了最后的轮值,即Xml文档,Close &重新启用,我能够读到XML文件的最后准确价值。
但是,由于最后的轮换价值不是实际的轮换价值,所以图像并非完全轮换到最后状态。
因此,我也尝试将硬编码价值和图像完全轮换。
self.transform = CGAffineTransformMakeRotation(1.57);//By 90 Degree
因此,如何找到准确的图像轮换价值。