gpt4 book ai didi

iPhone iOS 如何在启用缩放时使 UIScrollView 与 UIRotationGestureRecognizer 一起工作?

转载 作者:行者123 更新时间:2023-11-28 17:35:56 25 4
gpt4 key购买 nike

我在 iOS5 中工作,显然我应该能够使用 scrollView.pinchGestureRecognizer 控制或至少制服 UIScrollView 的内部捏合手势识别器。

但是,我的代码似乎不起作用。识别器不会将我的类(class)视为委托(delegate),也不会等待我的旋转手势识别器失败。我该怎么做才能使旋转手势成为优先事项,然后再考虑捏合?

更准确地说,我遇到的问题是同时旋转和缩放的 View “飞出屏幕”向左下角移动,再也看不到了。

-(void)setup scrollViews
{
[tempScrollView.pinchGestureRecognizer requireGestureRecognizerToFail:rotationRecognizer];
tempScrollView.pinchGestureRecognizer.delegate = self;

tempScrollView.maximumZoomScale = 4.0;
tempScrollView.minimumZoomScale = 0.25;
//
tempScrollView.delegate = self;
}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{

if([gestureRecognizer isEqual:rotationRecognizer])
{
NSLog(@"Rotation gesture");
}else {
NSLog(@"Other gesture: %@", [gestureRecognizer class]);
}
return YES;

}

- (IBAction)rotateView:(id)sender {

if([sender isKindOfClass:[UIRotationGestureRecognizer class]])
{
UIRotationGestureRecognizer* recognizer = sender;

float recognizerRotation = [recognizer rotation];
CGAffineTransform transform = CGAffineTransformMakeRotation(recognizerRotation);
activeView.transform = transform;

}

}

最佳答案

据我所知,UIScrollView 中的pinchGestureRecognizer 是只读的。但是,您可以尝试子类化 UIScrollView 并覆盖方法 addGestureRecognizer: 以禁用 pinchGestureRecognizer,然后添加您自己的自定义 pinchGestureRecognizer.

关于iPhone iOS 如何在启用缩放时使 UIScrollView 与 UIRotationGestureRecognizer 一起工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9816316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com