gpt4 book ai didi

iOS 长按不适用于 map

转载 作者:行者123 更新时间:2023-11-29 00:53:52 25 4
gpt4 key购买 nike

我试图在长按以在该位置周围绘制覆盖图后获取该位置。但是,我设置的长按 Action 并没有触发。

-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];

//add the long press options

//single finger long press
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(getMapCoordinateFromTouch:)];
[longPressGesture setNumberOfTouchesRequired:1];
longPressGesture.delegate = self;
[self.mapview addGestureRecognizer:longPressGesture];

//double finger long press
UILongPressGestureRecognizer *doubleLongPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(removeBoundry:)];
[doubleLongPressGesture setNumberOfTouchesRequired:2];
doubleLongPressGesture.delegate = self;
[self.mapview addGestureRecognizer:doubleLongPressGesture];

这是它调用的函数

-(void)getMapCoordinateFromTouch:(UILongPressGestureRecognizer *) gesture{
if(gesture.state == UIGestureRecognizerStateBegan){
CGPoint touchlocation = [gesture locationInView:self.mapview];
pressedloc = [self.mapview convertPoint:touchlocation toCoordinateFromView:self.mapview];
[self createBundarywithRadius:.1];
}

最佳答案

很酷,所以你的 mapview 对象是 nil。

如果您使用的是界面构建器,那么您还没有将您的属性附加到可视组件。这是基本的东西,有很多关于如何做这种事情的教程。

简而言之,您应该已经有了类似的东西:

@property (nonatomic, weak) IBOutlet MKMapView *mapview;

这没有连接到界面构建器组件,那是你的问题!

快乐编码...

关于iOS 长按不适用于 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37814216/

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