2013-01-11 50 views
0

我一直試圖幾乎同時更新兩個UIImageView元素。應該改變其位置(image01),另一個應該改變其圖像文件(image02)。更新UIImageView圖像文件時,其他UIImageView的位置被重置爲中心

這裏的問題是,當我更改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; 
} 
+2

顯示一些代碼好嗎? – thelaws

+0

對不起,插入的代碼=] – inkytales

回答

0

我意識到這個問題是在屏幕重繪。

因此,而不是具有通過接口構建器插入元件,我編程插入它並保持軌道的位置的在可變=]

相關問題