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;
}
显示一些代码好吗? – thelaws
对不起,插入的代码=] – inkytales