带有 UIButtonTypeDetailDisclosure-Button 的路由标记标签 - 按钮不是可点击的
我的路线框架和标记标签有问题。我现在尝试了大约 5 个小时,但没有成功,并且搜索了网络上几乎所有有关此问题的论坛主题。 我想添加一个带有 UIButtonTypeDetailDisclosure-Button 的标记标签。 当我将按钮添加到应该是标签的 UIView 时,我无法单击按钮。
我的代码如下:
- (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'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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,我终于解决了这个问题。
也许这是一个有点肮脏的解决方法,但无论如何它正在工作;)
我修改了route-me框架并添加了一个名为的方法
在RMMapView.m中我在第584行中添加了以下行:
现在,点击了公开按钮这部分代码是执行并调用我的方法。
当点击标记标签的任何其他区域时,
将调用该方法。
希望这对其他人有帮助;)
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
In RMMapView.m I added the following Lines in Line 584:
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
method is called.
Hope this helps anyone else ;)
此问题已通过此拉取请求解决 https://github.com/route-me /route-me/pull/161。
它已于 2012 年 2 月 21 日合并到 Route-me 代码中。
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.
在路线谷歌群组列表中查看此线程:
http://groups.google.com/group/route-me -map/browse_thread/thread/343cb3ebfd9480e3
有人得到了一些使用关闭按钮的标记“气球”标签的代码的答复。
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.
我在这个解决方案上遇到了麻烦,我不想成为那些告诉你以不同方式做事的人之一,因为你可能有充分的理由按照你现在的方式做事。
我采用了这种初始方法,然后通过另一个线程我意识到:如果我只想一次有一个标注,我可以将他作为mapView的子视图进行管理,并使用mapView.markerManager的辅助方法。 RMMarker 对象有一个数据指针,您可以使用它来填充标注气泡的内容。
这节省了我很多时间,而且我有了一个令人满意的解决方案,而且根本不会弄脏。
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.