📄 touchimageview.m
字号:
//// TouchImageView.m// MultiTouchDemo//// Created by Jason Beaver on 5/29/08.// Copyright 2008 Apple Inc.. All rights reserved.//#import "TouchImageView.h"#import "TouchImageView_Private.h"#include <execinfo.h>#include <stdio.h>@implementation TouchImageView@synthesize image;- (id)initWithFrame:(CGRect)frame{ if ([super initWithFrame:frame] == nil) { return nil; } originalTransform = CGAffineTransformIdentity; touchBeginPoints = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); self.userInteractionEnabled = YES; self.multipleTouchEnabled = YES; self.exclusiveTouch = YES; return self;}- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSMutableSet *currentTouches = [[[event touchesForView:self] mutableCopy] autorelease]; [currentTouches minusSet:touches]; if ([currentTouches count] > 0) { [self updateOriginalTransformForTouches:currentTouches]; [self cacheBeginPointForTouches:currentTouches]; } [self cacheBeginPointForTouches:touches];}- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ CGAffineTransform incrementalTransform = [self incrementalTransformWithTouches:[event touchesForView:self]]; self.transform = CGAffineTransformConcat(originalTransform, incrementalTransform);}- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { if (touch.tapCount >= 2) { [self.superview bringSubviewToFront:self]; } } [self updateOriginalTransformForTouches:[event touchesForView:self]]; [self removeTouchesFromCache:touches]; NSMutableSet *remainingTouches = [[[event touchesForView:self] mutableCopy] autorelease]; [remainingTouches minusSet:touches]; [self cacheBeginPointForTouches:remainingTouches];}- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ [self touchesEnded:touches withEvent:event];}- (void)dealloc{ CFRelease(touchBeginPoints); [super dealloc];}@end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -