gpt4 book ai didi

iphone - 缺少 UIView 的 anchorPoint 属性

转载 作者:可可西里 更新时间:2023-11-01 03:35:57 24 4
gpt4 key购买 nike

我使用的代码来自 apple 的 Touches code (我刚刚将 piece 的变量名更改为 image):

- (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
UIView *image = gestureRecognizer.view;
CGPoint locationInView = [gestureRecognizer locationInView:image];
CGPoint locationInSuperview = [gestureRecognizer locationInView:image.superview];

// Gives error: Property 'anchorPoint' not found on object of type 'CALayer *'
//image.layer.anchorPoint = CGPointMake(locationInView.x / image.bounds.size.width, locationInView.y / image.bounds.size.height);
// Gives warning: Method '-setAnchorPoint' not found
[image.layer setAnchorPoint:CGPointMake(locationInView.x / image.bounds.size.width, locationInView.y / image.bounds.size.height)];
image.center = locationInSuperview;
}
}

但是,如评论中所述,image.layer.anchorPoint 无法编译,并出现无法找到“anchorPoint”属性的错误。当用消息传递重写该行时它会编译,但它仍然会给出警告。

直接复制并粘贴 Touches 代码而不更改变量名称会产生相同的错误。当我编译 Touches 代码时,这些错误也不会出现。

这是为什么?

最佳答案

您可能还没有包含 QuartzCore 框架,这是使用 CALayer 所必需的。

你需要添加

#import <QuartzCore/QuartzCore.h>

关于iphone - 缺少 UIView 的 anchorPoint 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6648285/

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