Как добавить кнопку на Google maps в iOS?

Я новичок в программировании для iOS, и я скачал SDK Google Maps для iOS и следовал инструкциям на их сайте (как показано в этой ссылкеhttps://developers.google.com/maps/documentation/ios/start ) и смог получить карту в моем приложении.

Теперь я пытаюсь добавить кнопку внизу экрана над картами Google, чтобы дать пользователю возможность вернуться к предыдущему экрану.

Я просто знаю, что UIButton является подклассом UIView, и мы можем сделать так, чтобы кнопка отображалась в представлении, сделав его вложенным представлением этого класса. Ранее iOS по умолчанию использовала Google Maps от MKMapView, и я видел примеры в книгах и в Интернете, где показаны снимки экрана приложений, в которых кнопка или текстовое поле появлялись на карте. Но теперь просто перетаскивая кнопку в конструкторе интерфейсовпомочь с SDK карт Google.

Вот мой код:

ViewController.h

#import 
#import 
#import 


@interface ViewController : UIViewController 

@property (weak, nonatomic) IBOutlet UIButton *btn;


@end

ViewController.m

#import "ViewController.h"
#import 
#import 
#import 


@interface ViewController ()

@end

@implementation ViewController
{
    GMSMapView *mapView_;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)loadView
{
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    locationManager.distanceFilter = kCLDistanceFilterNone;

    locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
    [locationManager startUpdatingLocation];

    //Latitude and longitude of the current location of the device.
    double lati = locationManager.location.coordinate.latitude;
    double longi = locationManager.location.coordinate.longitude;
    NSLog(@"Latitude = %f", lati);
    NSLog(@"Longitude = %f", longi);

    CLLocation *myLocation = [[CLLocation alloc] initWithLatitude:lati longitude:longi];

    // Create a GMSCameraPosition that tells the map to display the coordinate

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:lati
                                                            longitude:longi
                                                                 zoom:11.5];

    mapView_ = [GMSMapView mapWithFrame:[[UIScreen mainScreen] bounds] camera:camera];
    mapView_.myLocationEnabled = YES;
    self.view = mapView_;

    // Creates a marker in the center of the map.
    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(lati, longi);
    marker.title = @"It's Me";
    marker.snippet = @"My Location";
    marker.map = mapView_;

    [mapView_ addSubview:_btn];
    [mapView_ bringSubviewToFront:_btn];

}
@end

Вы можете видеть, что в последних 2 строках я сделал кнопку подпредставлением mapview и попытался вывести ее вперед. Но это неТ помочь. Пожалуйста, дайте мне знать, что мне не хватает или есть ли другой способ сделать это с помощью какой-либо другой функции.

Пожалуйста, проверьте скриншот созданной мной раскадровки, чтобы вы могли лучше понять, что я пытаюсь сделать здесь.

Благодарю.

Ответы на вопрос(3)

Ваш ответ на вопрос