문제

I'm trying to invoke keyboard for typing on a UITextField. This is how I add the UITextField:

@implementation SOViewController{
   GMSMapView *mapView_; 
}


- (void)viewDidLoad
{

 self.view = mapView_;
 UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(20, 20, 190, 200)];
 [tf setText:@"test"];

 [self.view addSubview:tf];

}

Is it because of the mapview properties? Is there an alternative for this?

도움이 되었습니까?

해결책 2

 locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:locationManager.location.coordinate.latitude
                                                        longitude:locationManager.location.coordinate.longitude
                                                             zoom:16];

mapView_ = [GMSMapView mapWithFrame:CGRectMake(0, 44, self.view.bounds.size.width, self.view.bounds.size.height-44) camera:camera];
mapView_.myLocationEnabled = YES;
[self.view addSubview:mapView_];

다른 팁

add this if you need touches enable in uitextfield

 for (id gestureRecognizer in mapView_.gestureRecognizers)
    {
        NSLog(@"mapview recognizer %@",gestureRecognizer);
        if (![gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]])
        {
            [mapView_ removeGestureRecognizer:gestureRecognizer];
        }
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top