0

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;
}
4

1 に答える 1

0

画面の再描画に問題があることに気づきました。

そのため、インターフェイスビルダーを介して要素を挿入する代わりに、プログラムで要素を挿入し、変数内の位置を追跡しました=]

于 2013-01-12T17:41:30.873 に答える