How to add a button on the Google maps in iOS?

后端 未结 5 2077
北海茫月
北海茫月 2021-02-05 16:44

I am new to iOS Programming and I have downloaded the google maps sdk for iOS and followed the instruction on their website ( as shown in this link https://developers.google.com

5条回答
  •  余生分开走
    2021-02-05 17:10

    I faced the same issue and the fix is very easy, just override this UIViewController method:
    -(void) viewWillAppear:(BOOL)animated and put your UIButton creation logic inside that method.

    Example:

    -(void) viewWillAppear:(BOOL)animated
    {
     locationButton = [UIButton buttonWithType:UIButtonTypeCustom];
     locationButton.frame = CGRectMake(0, 30, self.view.frame.size.width/6, self.view.frame.size.height/6);
     [locationButton setImage:[UIImage imageNamed:@"location_enabled.png"] forState:UIControlStateNormal];
     [self.view addSubview:locationButton];
    }
    

提交回复
热议问题