我在我的地图上有一个自定义MKOverlayView,我想检测触摸.但是,我似乎无法得到叠加层来回应.我希望它会像忘记将userInteractionEnabled设置为YES那样愚蠢......但是唉,那里没有运气
....目前,这是我如何拥有它:
//map delegate overlay:
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
if (_radiusView !=nil) {
[_radiusView removeFromSuperview];
[_radiusView release];
_radiusView = nil;
}
_radiusView = [[CustomRadiusView alloc]initWithCircle:overlay];
_radiusView.userInteractionEnabled = YES;
_radiusView.strokeColor = [UIColor blueColor];
_radiusView.fillColor = [UIColor grayColor];
_radiusView.lineWidth = 1.0;
_radiusView.alpha = 0;
//fade in radius view
[UIView beginAnimations:@"fadeInRadius" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.6];
_radiusView.alpha = .3;
[UIView commitAnimations];
return _radiusView;
}
Run Code Online (Sandbox Code Playgroud)
我的自定义overlay类只是实现了touchesBegan,并扩展了MKCircleView
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touch!");
}
Run Code Online (Sandbox Code Playgroud) - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
{
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Send to Twitter"
style:UIBarButtonItemStyleDone
target:self
action:@selector(save)];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
另一段代码
- (void)loadView
{
[super loadView];
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.view.backgroundColor = [UIColor whiteColor];
self.textView = [[UITextView alloc] initWithFrame:self.view.bounds];
textView.delegate = self;
textView.font = [UIFont systemFontOfSize:15];
textView.contentInset = UIEdgeInsetsMake(5,5,0,0);
textView.backgroundColor = [UIColor whiteColor];
textView.autoresizesSubviews = YES;
textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view …Run Code Online (Sandbox Code Playgroud) 是 O(n) 还是 O(log n)