0
我試圖放大和縮小的ImageView的縮放手勢不與ImageView的
在這裏工作是代碼
- (void)pinch:(UIPinchGestureRecognizer *)gesture
{
if (handSelected == YES)
{
if (gesture.state == UIGestureRecognizerStateEnded || gesture.state == UIGestureRecognizerStateChanged)
{
NSLog(@"gesture.scale = %f", gesture.scale);
CGFloat currentScale = self.imgHand.frame.size.width/self.imgHand.bounds.size.width;
CGFloat newScale = currentScale * gesture.scale;
if (newScale < 1.0) {
newScale = 1.0;
}
if (newScale > 4.0) {
newScale = 4.0;
}
CGAffineTransform transform = CGAffineTransformMakeScale(newScale, newScale);
self.imgHand.transform = transform;
gesture.scale = 1;
}
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self adjustRingPressed:self];
self.view.multipleTouchEnabled = YES;
self.imgHand.multipleTouchEnabled = YES;
UIPinchGestureRecognizer *gst = [[UIPinchGestureRecognizer alloc] initWithTarget:self.imgHand action:@selector(pinch:)];
[gst setDelegate:self];
[self.imgHand addGestureRecognizer:gst];
}
看來我的捏代碼永遠不會運行
嘗試設置目標自我並添加手勢識別到self.view – Marc 2013-03-25 13:35:47