Tôi đang sử dụng Google Maps trong Ứng dụng iOS và đã triển khai cửa sổ thông tin tùy chỉnh để hiển thị tiêu đề của điểm đánh dấu.
Bây giờ, tôi đã thêm một nút trên cửa sổ thông tin tùy chỉnh đó nhưng vấn đề của tôi là phương thức hành động nút không được gọi.Nút trên Thông tin tùy chỉnh Cửa sổ không nhận được hành động trong ios
CustomInfoWindow.h
#import <UIKit/UIKit.h>
@interface CustomInfoWindow : UIView
@property (nonatomic,weak) IBOutlet UILabel *addressLabel;
@property(nonatomic) IBOutlet UIButton *button;
@end
và trong infoWindow.xib
, tôi đã thêm
UILabel
gọiaddressLabel
UIButton
gọibutton
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");
}
Về cơ bản ... ButtonPressed
phương pháp không cháy.
không 'infoWindow.addressLabel.text = marker.title; 'làm việc? (_just ask_) – staticVoidMan
Ya làm việc nó đang hiển thị địa chỉ trên nhãn đó. – iSuresh