簡體   English   中英

在ios 9中使用GMSPlace Picker時應用崩潰

[英]App Crash while using GMSPlace Picker in ios 9

當用戶未從選擇器視圖中選擇任何位置並按“返回”按鈕時,GMSPlacePicker會崩潰。

錯誤:

- [UIWindow _shouldAnimatePropertyWithKey:]:發送到解除分配的實例的消息

碼:

- (void)findNearByPlace :(CLLocationCoordinate2D)center {


CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(center.latitude + 0.001,
                                                              center.longitude + 0.001);
CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(center.latitude - 0.001,
                                                              center.longitude - 0.001);
GMSCoordinateBounds *viewport = [[GMSCoordinateBounds alloc] initWithCoordinate:northEast
                                                                     coordinate:southWest];
GMSPlacePickerConfig *config = [[GMSPlacePickerConfig alloc] initWithViewport:viewport];
_placePicker = [[GMSPlacePicker alloc] initWithConfig:config];

[_placePicker pickPlaceWithCallback:^(GMSPlace *place, NSError *error) {
    if (error != nil) {
        NSLog(@"Pick Place error %@", [error localizedDescription]);
        return;
    }
    if (place != nil) {
        NSLog(@"Place name:%@",place.formattedAddress);
        placeName = place.name;
        placeAddress = place.formattedAddress;
        //hide previous marker
        self.mapMarker.map = nil;
        self.locaitonTitle = place.name;
        self.locationAddress = place.formattedAddress;
        self.mapMarker = [GMSMarker markerWithPosition:place.coordinate];
        self.mapMarker.icon = [UIImage imageNamed:@"ic_ellipse_black.png"];
        mapLattitude = place.coordinate.latitude;
        mapLongitude = place.coordinate.longitude;
        self.mapMarker.draggable = YES;
        markerTag = @"2";
        markerDefault = @"default";
        self.mapMarker.userData = @{};
        self.mapMarker.map = self.mapView_;
        [self showLocationPopUp:placeName address:placeAddress withCoord:place.coordinate];
        //[self showLocationFoundView];
    } else {

        [self addOwnLocation : longPressCoord];
        NSLog(@"No Place is selected yet");
    }
}];

}

任何方案?

我們遇到了同樣的問題。 我們的解決方案是通過隱藏導航欄來禁用Back導航按鈕。

Objective-C的:

[placePicker pickPlaceWithCallback:^(GMSPlace * __nullable result, NSError * __nullable error) {
    //DO SOMETHING
}];

//Hide the navigation bar
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    UINavigationController *rootViewController = (UINavigationController *)[[[UIApplication sharedApplication] keyWindow] rootViewController];
    rootViewController.navigationBarHidden = true;
});

迅速:

placePicker.pickPlaceWithCallback({ (place: GMSPlace?, error: NSError?) -> Void in
    //DO SOMETHING     
})

//Hide the navigation bar
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.5 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue(), { () -> Void in
     let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController
     (rootViewController as! UINavigationController).navigationBarHidden = true
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM