iOS Google Maps textField not Responding

后端 未结 4 616
借酒劲吻你
借酒劲吻你 2020-12-10 19:53
#import \"MyLocationViewController.h\"
#import 


@interface MyLocationViewController ()

@end

@implementation MyLocationViewControll         


        
相关标签:
4条回答
  • 2020-12-10 20:11

    Add this if you need touch event enable in uitextfield

    for (id gestureRecognizer in mapView_.gestureRecognizers)
        {
            NSLog(@"mapview recognizer %@",gestureRecognizer);
            if (![gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]])
            {
                [mapView_ removeGestureRecognizer:gestureRecognizer];
            }
        }
    
    0 讨论(0)
  • 2020-12-10 20:12

    The googleMapView has a BlockingGestureRecognizer that blocks all user input. don't add the textfield to the map OR remove the blocker:

    // Remove the GMSBlockingGestureRecognizer of the GMSMapView.
    + (void)removeGMSBlockingGestureRecognizerFromMapView:(GMSMapView *)mapView
    {
        if([mapView.settings respondsToSelector:@selector(consumesGesturesInView)]) {
            mapView.settings.consumesGesturesInView = NO;
        }
        else {
            for (id gestureRecognizer in mapView.gestureRecognizers)
            {
                if (![gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]])
                {
                    [mapView removeGestureRecognizer:gestureRecognizer];
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-10 20:18

    Try

    [self.view addSubview: textField];  
    

    Instead of

    [mapView_ addSubview:textField];  
    

    This may help you.

    0 讨论(0)
  • 2020-12-10 20:27

    Add Your UITextfield or UISearchbar in to subview of Mapview_

    UISearchBar *search;
    search = [[UISearchBar alloc] init];
        [search setTintColor:[UIColor colorWithRed:233.0/255.0
                                             green:233.0/255.0
                                              blue:233.0/255.0
                                             alpha:1.0]];
        search.frame = CGRectMake(50,20,self.view.frame.size.width-70,32);
        search.delegate = self;
        search.placeholder = @"MapView";
    [mapView_ addSubview:search];
    

    Add Following method to your .m file

    // Remove the GMSBlockingGestureRecognizer of the GMSMapView.
    + (void)removeGMSBlockingGestureRecognizerFromMapView:(GMSMapView *)mapView
    {
        for (id gestureRecognizer in mapView.gestureRecognizers)
        {
            NSLog(@"mapview recognizer %@",gestureRecognizer);
            if (![gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]])
            {
                [mapView removeGestureRecognizer:gestureRecognizer];
            }
        }
    }
    

    Call This Method from your view will appear

    - (void)viewWillAppear:(BOOL)animated {
        [ViewController removeGMSBlockingGestureRecognizerFromMapView:mapView_];
    
    }
    

    Now it will work , i got tested with this code only.

    0 讨论(0)
提交回复
热议问题