开发者

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

I've got a proble开发者_Go百科m 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!


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 ;)


This issue is resolved by this pull request https://github.com/route-me/route-me/pull/161.

It has been merged in route-me code on feb 21st 2012.


Take a look to this thread in the route google groups list: http://groups.google.com/group/route-me-map/browse_thread/thread/343cb3ebfd9480e3

someone was answered with some code for marker "balloon" labels that uses a close button.


I had trouble with this solution, and I don't want to be one of those people who tell you to do it differently because you may have good cause to do things the way you are doing them.

I took this initial approach, then via another thread I realized: If I only want to have one callout at a time, I can just manage him as a subview of the mapView and use the helper methods of the mapView.markerManager. A RMMarker object has a data pointer which you can use to fill in the contents of your callout bubble.

This saved me a lot of time and I have a satisfactory solution that doesn't get that dirty at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜