【发布时间】:2012-08-01 02:48:50
【问题描述】:
致力于通过触摸将图像添加到视图中。到目前为止,我的代码允许我在触摸屏幕时添加我想要多次选择的相同图像。我希望能够一次只添加一张图片,这样我就可以操作添加的图片(放大/缩小、旋转、移动)。
我应该如何修改我的代码以允许这样做?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch * touch = [touches anyObject];
touchPoint = [touch locationInView:imageView];
if (touchPoint.x > 0 && touchPoint.y > 0)
{
stampedImage = _imagePicker.selectedImage;
_stampedImageView = [[UIImageView alloc] initWithImage:stampedImage];
_stampedImageView.multipleTouchEnabled = YES;
_stampedImageView.userInteractionEnabled = YES;
[_stampedImageView setFrame:CGRectMake(touchPoint.x, touchPoint.y, 80.0, 80.0)];
_stampedImageView.center = touchPoint;
[imageView addSubview:_stampedImageView];
[_stampedImageView release];
}
}
谢谢!
【问题讨论】:
标签: objective-c cocoa-touch uiimageview uiimage touchesbegan