相关疑难解决方法(0)

如何拦截触摸MKMapView或UIWebView对象上的事件?

我不确定我做错了什么,但我试图抓住一个MKMapView物体.我通过创建以下类来继承它:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface MapViewWithTouches : MKMapView {

}

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event;   

@end
Run Code Online (Sandbox Code Playgroud)

并实施:

#import "MapViewWithTouches.h"
@implementation MapViewWithTouches

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event {

    NSLog(@"hello");
    //[super touchesBegan:touches   withEvent:event];

}
@end
Run Code Online (Sandbox Code Playgroud)

但看起来当我使用这个类时,我在控制台上看不到任何内容:

MapViewWithTouches *mapView = [[MapViewWithTouches alloc] initWithFrame:self.view.frame];
[self.view insertSubview:mapView atIndex:0];
Run Code Online (Sandbox Code Playgroud)

知道我做错了什么吗?

cocoa-touch objective-c iphone-sdk-3.0 mkmapview ios

96
推荐指数
5
解决办法
8万
查看次数

用iOS7检测MKPolygon中的一个点(CGPathContainsPoint)

在我今年早些时候提出的SO问题中,我得到了这段代码:

MKPolygonView *polygonView = (MKPolygonView *)[self.mapView viewForOverlay:polygon];
MKMapPoint mapPoint = MKMapPointForCoordinate(tapCoord);
CGPoint polygonViewPoint = [polygonView pointForMapPoint:mapPoint];

if (CGPathContainsPoint(polygonView.path, NULL, polygonViewPoint, FALSE)) {
    // do stuff
}
Run Code Online (Sandbox Code Playgroud)

这在iOS7之前很有用.它现在总是返回false,并且不会检测带路径的点.

我正在尝试找到任何说明该方法更改的文档,但找不到任何文档.

任何想法为什么它破了?还是新的解决方案?

objective-c mapkit mkmapview ios

12
推荐指数
1
解决办法
7089
查看次数