自定义信息窗口上的按钮未在ios中接收 *** 作

自定义信息窗口上的按钮未在ios中接收 *** 作,第1张

概述我在iOS应用程序中使用谷歌地图,并实现了一个自定义信息窗口,用于显示标记的标题. 现在,我在该自定义信息窗口上添加了一个按钮,但我的问题是没有调用按钮 *** 作方法. CustomInfoWindow.h #import <UIKit/UIKit.h>@interface CustomInfoWindow : UIView@property (nonatomic,weak) IBOutlet U 我在iOS应用程序中使用谷歌地图,并实现了一个自定义信息窗口,用于显示标记的标题.
现在,我在该自定义信息窗口上添加了一个按钮,但我的问题是没有调用按钮 *** 作方法.

CustomInfoWindow.h

#import <UIKit/UIKit.h>@interface CustomInfoWindow : UIVIEw@property (nonatomic,weak) IBOutlet UILabel *addressLabel;@property(nonatomic) IBOutlet UIbutton *button;@end

在infoWindow.xib中,我添加了

> UILabel称为addressLabel
> UIbutton称为按钮

VIEwController.h

#import "CustomInfoWindow.h"@interface vIEwController : UIVIEwController<GMSMapVIEwDelegate>{  GMSMapVIEw *mapVIEw;}@end

VIEwController.m

- (UIVIEw *)mapVIEw:(GMSMapVIEw *)mapVIEw markerInfoWindow:(GMSMarker *)marker{    NSLog(@"Mrker Tapped");    CustomInfoWindow *infoWindow = [[[NSBundle mainBundle]loadNibnamed:@"infoWindow"                                                                 owner:self                                                               options:nil] objectAtIndex:0];    infoWindow.addressLabel.text = marker.Title;        [infoWindow.button addTarget:self action:@selector(buttonpressed)                             forControlEvents:UIControlEventtouchUpInsIDe];    return infoWindow;}-(voID)buttonpressed{    NSLog(@"button pressed");}

基本上…… buttonpressed方法不会触发.

解决方法 我没有使用谷歌地图SDK但是在看了几个链接之后,看起来你想要完成的事情可能并不容易.

ref:https://developers.google.com/maps/documentation/android/infowindows
PS:这可能是AndroID文档,但它似乎也适用于iOS.

报价:

Note: The info window that is drawn is not a live vIEw. The vIEw is
rendered as an image (using VIEw.draw(Canvas)) at the time it is
returned. This means that any subsequent changes to the vIEw will not
be reflected by the info window on the map. To update the info window
later (for example,after an image has loaded),call showInfoWindow().
Furthermore,the info window will not respect any of the interactivity
typical for a normal vIEw such as touch or gesture events. However you
can Listen to a generic click event on the whole info window as
described in the section below.

您可以改为实施GMSMapViewDelegate’s -didTapInfoWindowOfMarker:委托方法来检查信息窗是否被点击.
(缺点是整个infowindow成为一个按钮)

其他链接:

similar question 1
similar question 2

总结

以上是内存溢出为你收集整理的自定义信息窗口上的按钮未在ios中接收 *** 作全部内容,希望文章能够帮你解决自定义信息窗口上的按钮未在ios中接收 *** 作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1069555.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存