相关疑难解决方法(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万
查看次数