我不确定我做错了什么,但我试图抓住一个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)
知道我做错了什么吗?