2 つの UIImageView 要素をほぼ同時に更新しようとしています。1 つは位置を変更する必要があり (image01)、もう 1 つはイメージ ファイルを変更する必要があります (image02)。
ここでの問題は、image02 の画像ファイルを変更すると、image01 の位置データが中央 (要素の原点) にリセットされることです。
私は完全にここにいます。これを引き起こしている原因について何か考えはありますか?
コードは次のとおりです。
- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch* touch = [touches anyObject];
CGPoint point = [touch locationInView:self.view];
// Setting crosshair new position
[self setCrossHairPosition:point];
// Getting camera preview, and discovering pixel color at touch location
// I also set colorName here
[self captureNow:touch];
// Getting file and inserting it in the UIImageView
fileName = [NSString stringWithFormat:@"%@.png", colorName];
_colorADDPreview.image = [UIImage imageNamed:fileName];
}
- (void) setCrossHairPosition:(CGPoint)point {
CGRect crossHairRect = _crossHair.frame;
crossHairRect.origin.x = point.x - (crossHairRect.size.width/2);
crossHairRect.origin.y = point.y - (crossHairRect.size.height/2);
_crossHair.frame = crossHairRect;
}