iphoneuiviewuibuttonmarkerroute-me

route-me marker label with UIButtonTypeDetailDisclosure-Button - Button isn't clickabel


I've got a problem with the route-me framework and marker labels. I'm trying now about 5 hours with no luck and searched almost every forum topic on the web about this. I want to add a marker label with a UIButtonTypeDetailDisclosure-Button on it. When I add the Button to the UIView that should be the label I can't click on the Button.

My code is as follows:

- (void)tapOnMarker:(RMMarker*)marker onMap:(RMMapView*)map {
    UIView *frame = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    button.frame = CGRectMake(0, 0, 34, 34);
    button.enabled = YES;
    button.userInteractionEnabled = YES;
    [button addTarget:self action:@selector(markerLabelButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

    [frame addSubview:button];
    [marker setLabel:frame];
    [marker showLabel];
}

-(void)markerLabelButtonPressed:(id)sender {
    NSLog(@"pressed");
}

I hope anyone may help me with this. Thanks :)

I you need any more information please let me know!


Solution

  • Ok finally i managed to solve the problem. Maybe it's a little dirty workaround, but anyway it's working ;)

    I modified the route-me framework and added a method called

    - (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map onLayer:(CALayer *)layer;
    

    In RMMapView.m I added the following Lines in Line 584:

     else if ([superlayer superlayer] != nil && [[[superlayer superlayer] superlayer] isKindOfClass: [RMMarker class]]) {
         if (_delegateHasTapOnLabelForMarker) {
             [delegate tapOnLabelForMarker:(RMMarker*)[[superlayer superlayer] superlayer] onMap:self onLayer:superlayer];
         }
     } 
    

    Now then the disclosurebutton is tapped this part of the code is executed and my method is called. When any other area of the marker label is tapped the

    - (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map;
    

    method is called.

    Hope this helps anyone else ;)