我编写了一个用于裁剪目的的代码。场景就像,它有4个uiviews
1) 上
2) 左
3) 右
4) 下
每个 uiview 都会根据所需的更改调整大小,并且主 uiview 有一个包含图像的 uiimageview。当我在 iPhone 3、3GS、iPad 2、iPad 4 上运行代码时,它运行良好,但是当我在 iPhone 4G 上运行它时,它会产生非常不希望的结果。我知道我的代码计算很好,这就是为什么它们在除 iPhone 4G 之外的所有设备上都能正常工作的原因。问题会是什么?有任何想法吗 ?iPhone 4的uiview计算是否不同或任何其他原因?
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
// messageLabel.text = @"Drag Detected";
commonCropT = leftRect.frame.origin.y; // left.y or Right.y or Top.H is same thing
commonCropB = lowerRect.frame.origin.y;// left.H or Right.H or lower.y is same thing
commonCropL = leftRect.frame.size.width; //
commonCropR = rightRect.frame.origin.x;//
commonCropH = leftRect.frame.size.height;// left.width and right.width
leftYT = leftRect.frame.origin.y;
leftH = leftRect.frame.size.height;
leftYB = leftYT + leftH;
leftW = leftRect.frame.size.width; // leftXR
rightXL = rightRect.frame.origin.x;
rightW = rightRect.frame.size.width;
rightXR = rightXL + rightW;
rightYT = rightRect.frame.origin.y;
rightH = rightRect.frame.size.height;
rightYB = rightH + rightYT;
if (isTappedOnUpperLeftCorner)
{
if (commonCropR - movedPoint.x <= kWidthDifference)
return;
if (movedPoint.y < commonCropT )
{
commonCropH = commonCropH + (commonCropT - movedPoint.y);
}
else if (movedPoint.y > commonCropT )
{
if (commonCropB - movedPoint.y <= kHeightDifference ) {
return;
}
commonCropH = commonCropH - (movedPoint.y - commonCropT);
}
commonCropL = movedPoint.x;
commonCropT = movedPoint.y;
NSLog(@" cropW = %d ",cropW);
[upperRect setFrame:CGRectMake(upperRect.frame.origin.x, upperRect.frame.origin.y, upperRect.frame.size.width, commonCropT)];
[leftRect setFrame:CGRectMake(leftRect.frame.origin.x, commonCropT, commonCropL, commonCropH)];
[rightRect setFrame:CGRectMake(commonCropR, commonCropT, rightRect.frame.size.width, commonCropH)];
}
}