我正在尝试旋转添加到主视图的自定义视图。我试图将手势识别器添加到主视图和子视图。这是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *demoView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
UIRotationGestureRecognizer *rg= [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
[rg setDelegate:self];
self.view.userInteractionEnabled = YES;
demoView.userInteractionEnabled = YES;
[demoView addGestureRecognizer:rg];
[self.view addGestureRecognizer:rg];
demoView.backgroundColor = [UIColor orangeColor];
[self.view addSubview:demoView];
}
-(IBAction)handleTap:(UIRotationGestureRecognizer *)recognizer
{
//NSLog(@"HERE");
recognizer.view.transform = CGAffineTransformMakeRotation([recognizer rotation]);
recognizer.rotation = 0;
//NSLog(@"AND HERE");
}