gpt4 book ai didi

ios - UILongPressGestureRecognizer 按下坐标

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:09:01 26 4
gpt4 key购买 nike

我以这种方式在 UIImageView 上使用 UILongPressGestureRecogniser:

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[ImageViewPhotoCard addGestureRecognizer:longPress];


- (void)longPress:(UILongPressGestureRecognizer*)gesture {
if ( gesture.state == UIGestureRecognizerStateEnded ) {

//NSString *key = [array objectAtIndex:i];

UIButton* ButtonNote = [UIButton buttonWithType:UIButtonTypeRoundedRect];
ButtonNote.frame = CGRectMake(100, 200, 80, 80); // position in the parent view and set the size of the button

[ButtonNote addTarget:self action:@selector(OpenNote:) forControlEvents:UIControlEventTouchUpInside];
ButtonNote.backgroundColor = [UIColor clearColor];

UIImage* btnImage = [UIImage imageNamed:@"purple_circle.png"];
[ButtonNote setBackgroundImage:btnImage forState:UIControlStateNormal];

[self.ViewA addSubview:ButtonNote];

[ArrayNotes addObject:ButtonNote];

[ButtonNote setTitle:@"" forState:UIControlStateNormal];
[ButtonNote setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
}

如何获取用户按下的点的 x 和 y 坐标?

最佳答案

CGPoint location = [gesture locationInView:self.view];

可能是您正在寻找的。根据 self.view 坐标

,这会为您提供触摸点的 CGPoint

关于ios - UILongPressGestureRecognizer 按下坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18560395/

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