简单的问题
我正在开发适用于iOS的App,我在其中嵌入了适用于原生iOS的新Google Map.一切正常,除了一个问题,我无法在这里或谷歌找到本地IOS/Objective-C的propper解决方案(如果有一个请告诉我,抱歉让你讨厌)
我想要的是:我希望用户点击打开信息窗口的标记.如果他点击或点击信息窗口,它应该打开一个新的UIView与更多的信息.
我怎样才能做到这一点?
谢谢你的建议
objective-c onclick google-maps-markers ios google-maps-sdk-ios
我目前正在使用google maps ios SDK创建并返回自定义视图,方法是将委托设置为self并使用以下代码.
#pragma mark - GMSMapViewDelegate
-(UIView*)mapView:(GMSMapView *)mapView markerInfoWindow:(id<GMSMarker>)marker {
int popupWidth = 200;
int contentWidth = 180;
int contentPad = 10;
int popupHeight = 140;
int popupBottomPadding = 16;
int popupContentHeight = popupHeight - popupBottomPadding;
int buttonHeight = 30;
UIView *outerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, popupWidth, popupHeight)];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, popupWidth, popupContentHeight)];
[view setBackgroundColor:[UIColor whiteColor]];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(contentPad, 0, contentWidth, 22)];
[titleLabel setFont:[UIFont systemFontOfSize:17.0]];
titleLabel.text = [marker title];
UILabel …Run Code Online (Sandbox Code Playgroud) 我在iOS应用程序中使用谷歌地图,并实现了一个自定义信息窗口,用于显示标记的标题.
现在,我在该自定义信息窗口上添加了一个按钮,但我的问题是没有调用按钮操作方法.
CustomInfoWindow.h
#import <UIKit/UIKit.h>
@interface CustomInfoWindow : UIView
@property (nonatomic,weak) IBOutlet UILabel *addressLabel;
@property(nonatomic) IBOutlet UIButton *button;
@end
Run Code Online (Sandbox Code Playgroud)
在infoWindow.xib,我补充说
UILabel 叫 addressLabelUIButton 叫 buttonViewController.h
#import "CustomInfoWindow.h"
@interface viewController : UIViewController<GMSMapViewDelegate>
{
GMSMapView *mapView;
}
@end
Run Code Online (Sandbox Code Playgroud)
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");
}
Run Code Online (Sandbox Code Playgroud)
基本上...... ButtonPressed方法不会开火.
我创建了一个基于地图的iOS应用程序,其中我认为使用谷歌地图SDK for iOS而不是Mapkit,我找到了文档,但我没有找到与自定义注释视图相关的方法,任何人都可以为我提供如何解决方案创建自定义注释视图(信息窗口)以及如何为其添加内容(标题,代码段).