2016-10-15 9 views
0

私はアプリを開発中で、GoogleMapsとGooglePlaces SDKを統合しています。 iOS 10ベースのデバイスで開くと、検索バーをクリックするとアプリがクラッシュします。 GMSAutocompleteResultsViewControllerも追加しました。私はコードを添付していますGoogle Maps AutocompleteResultsViewControllerがiOS 10でクラッシュする

var mapView: GMSMapView? 

    var resultsViewController: GMSAutocompleteResultsViewController? 
    var searchController: UISearchController?   

    override func viewDidLoad() { 
     super.viewDidLoad() 

     mapView = GMSMapView() 
     mapView.frame = CGRectMake(0, 0, width, height) 
     mapView.mapType = kGMSTypeNormal 
     self.view.addSubview(mapView) 

     mapView.delegate = self 

     resultsViewController = GMSAutocompleteResultsViewController() 
     resultsViewController?.delegate = self 

     searchController = UISearchController(searchResultsController: resultsViewController) 
     searchController?.searchResultsUpdater = resultsViewController 

     searchController!.view.frame = CGRectMake(0, 0, width, height) 

     let subView = UIView(frame: CGRectMake(0, 0, width, 45.0)) 

     subView.addSubview((searchController?.searchBar)!) 
     self.view.addSubview(subView) 

     searchController?.hidesNavigationBarDuringPresentation = false 
     searchController?.modalPresentationStyle = UIModalPresentationStyle.Popover 

     self.definesPresentationContext = true 

     searchController?.searchBar.delegate = self 
    } 

    extension ViewController: GMSAutocompleteResultsViewControllerDelegate { 
     func resultsController(resultsController: GMSAutocompleteResultsViewController, didAutocompleteWithPlace place: GMSPlace) { 
      searchController?.active = false 

      mapView.animateToLocation(place.coordinate) 
     } 

     func resultsController(resultsController: GMSAutocompleteResultsViewController, didFailAutocompleteWithError error: NSError){ 
      print("Error: ", error.description) 
     } 

     func didRequestAutocompletePredictions(viewController: GMSAutocompleteViewController) { 
      UIApplication.sharedApplication().networkActivityIndicatorVisible = true 
     } 

     func didUpdateAutocompletePredictions(viewController: GMSAutocompleteViewController) { 
      UIApplication.sharedApplication().networkActivityIndicatorVisible = false 
     } 
    } 

    extension ViewController: UISearchBarDelegate { 
     func searchBarSearchButtonClicked(searchBar: UISearchBar) { 
      searchBar.resignFirstResponder() 
     } 

     func searchBarCancelButtonClicked(searchBar: UISearchBar) { 
      searchBar.resignFirstResponder() 
      searchController?.active = false 
     } 

     func searchBarTextDidBeginEditing(searchBar: UISearchBar) { 
      let doneBtn = self.navigationItem.rightBarButtonItem 
      doneBtn?.enabled = false 
     } 

     func searchBarTextDidEndEditing(searchBar: UISearchBar) { 
      let doneBtn = self.navigationItem.rightBarButtonItem 
      doneBtn?.enabled = true 
     } 
} 

私がsearchBarをタップすると、アプリは任意の文字を入力するとクラッシュします。私はどんな結果も見ず、一言も入力することはできません。私が得るエラーは

* thread #1: tid = 0x43622b, 0x1ca0f050 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2 
* thread #1: tid = 0x4382b9, 0x1ca0f050 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2 
* frame #0: 0x1ca0f050 libobjc.A.dylib`objc_exception_throw 
frame #1: 0x1d7a9d4c CoreFoundation`+[NSException raise:format:] + 108 
frame #2: 0x00933772 AppName`+[GMSPlacesClient sharedClient] + 122 
frame #3: 0x0092f702 AppName`-[GMSAutocompleteFetcher requestAutocompleteResultsWithText:] + 202 
frame #4: 0x0092f55a AppName`-[GMSAutocompleteFetcher sendOrDelayRequest:] + 82 
frame #5: 0x0092f4fa AppName`-[GMSAutocompleteFetcher sourceTextHasChanged:] + 82 
frame #6: 0x0093ad6a AppName`-[GMSAutocompleteTableDataSource sourceTextHasChanged:] + 234 
frame #7: 0x00943d7e AppName`-[GMSAutocompleteResultsViewController updateSearchResultsForSearchController:] + 202 
frame #8: 0x2321d736 UIKit`-[UISearchController _searchBar:textDidChange:] + 84 
frame #9: 0x229e202a UIKit`-[UISearchBar(UISearchBarStatic) _searchFieldEditingChanged] + 268 
frame #10: 0x22823b5c UIKit`-[UIApplication sendAction:to:from:forEvent:] + 76 
frame #11: 0x22823aea UIKit`-[UIControl sendAction:to:forEvent:] + 62 
frame #12: 0x2280dc86 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 470 
frame #13: 0x229e1da8 UIKit`-[UITextField fieldEditorDidChange:] + 218 
frame #14: 0x2282dd02 UIKit`-[UITextInputController _sendDelegateChangeNotificationsForText:selection:] + 122 
frame #15: 0x229b2c7a UIKit`-[UITextInputController _insertText:fromKeyboard:] + 822 
frame #16: 0x229b2008 UIKit`-[UITextInputController insertText:] + 406 
frame #17: 0x22b3d142 UIKit`-[UIFieldEditor insertFilteredText:] + 540 
frame #18: 0x231da3f0 UIKit`-[UITextField insertFilteredText:] + 96 
frame #19: 0x229b1d98 UIKit`-[UIKeyboardImpl insertText:] + 136 
frame #20: 0x22bf6e94 UIKit`-[UIKeyboardImpl performKeyboardOutput:] + 524 
frame #21: 0x22bf6ab6 UIKit`__55-[UIKeyboardImpl handleKeyboardInput:executionContext:]_block_invoke_2 + 334 
frame #22: 0x2281831a UIKit`-[UIKeyboardTaskQueue continueExecutionOnMainThread] + 400 
frame #23: 0x1e0cb3da Foundation`__NSThreadPerformPerform + 386 
frame #24: 0x1d765c8a CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12 
frame #25: 0x1d765794 CoreFoundation`__CFRunLoopDoSources0 + 438 
frame #26: 0x1d763a6a CoreFoundation`__CFRunLoopRun + 762 
frame #27: 0x1d6b3072 CoreFoundation`CFRunLoopRunSpecific + 486 
frame #28: 0x1d6b2e80 CoreFoundation`CFRunLoopRunInMode + 104 
frame #29: 0x1ee5bbfc GraphicsServices`GSEventRunModal + 156 
frame #30: 0x22859cce UIKit`-[UIApplication _run] + 574 
frame #31: 0x22854400 UIKit`UIApplicationMain + 150 
frame #32: 0x00232110 AppName`main + 172 at AppDelegate.swift:28 
frame #33: 0x1ce7e50a libdyld.dylib`start + 2 

です。このプロジェクトは、Swift 2.3のXcode 8を使用しています。

なぜこのエラーが発生しているのか分かりませんが、解決できません。それを調べてください。どんな助けもありがとう。

+0

iPadと非ipadのケースを区別するべきではありませんか? iPadはポップオーバープレゼンテーションを持たず、iPadの場合はポップオーバープレゼンターのバーアイテムまたはソースビューを設定する必要がありますか?よう:.popoverPresentationController.barButtonItem = barItem; –

+0

この[フォーラム](https://productforums.google.com/forum/#!topic/maps/9QR06XoF350)で議論されているように、使い勝手の問題に関連する可能性があります。ここでは、iOS 10のリリースで既に修正されているiOSをアップデートして、これが機能しているかどうかを確認してください。それでも問題が解決しない場合は、[Googleマップチームにフィードバックを送信する](https://support.google.com/maps/answer/3094045?co=GENIE.Platform%3DiOS&hl=ja&oco=1)あなたがiOS 10で抱えている問題。 – Teyam

+0

ねえ、解決策がありましたか? –

答えて

0

objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2

一部例外ブレークポイントを使用すると、検索バーをクリックすると明らかなように、GoogleマップやGooglePlacesのSDKの一部から、おそらくトリガーされるように見えます。

すべての例外の例外ブレークポイントを無効にします。

+0

@Danoramさんへの返信ありがとうございます。しかし、この例外ブレークポイントを追加して、問題のある箇所を特定しました。 –

1

次を置き換えます

旧:

@import GooglePlaces; 
[GMSPlacesClient provideAPIKey:GoogleAPIKey]; 

最新のSDKは、代わりにGoogleマップ/ GooglePlaces.hの、GooglePlaces/GooglePlaces.hを指している:作業コード更新

#import <GoogleMaps/GooglePlaces.h> 
[GMSServices provideAPIKey:GoogleAPIKey] 

このリンクをチェック: https://developers.google.com/places/migrate-to-v2

関連する問題