前提・実現したいこと
ここに質問の内容を詳しく書いてください。
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
Instance method 'mapView(mapView:regionDidChangeAnimated:)' nearly matches optional requirement 'mapView(_:regionDidChangeAnimated:)' of protocol 'MKMapViewDelegate'
Rename to 'mapView(_:regionDidChangeAnimated:)' to satisfy this requirement
Make 'mapView(mapView:regionDidChangeAnimated:)' private to silence this warning
### 該当のソースコード func mapView(mapView: MKMapView, regionDidChangeAnimated animated: Bool) { let currentLocation = mapView.centerCoordinate print(currentLocation) }
言語:Swift
環境:Xcode
### 試したこと ①マップの中心点から移動するとコンソールに「移動しました」と表示させる func mapView(mapView: MKMapView, regionDidChangeAnimated animated: Bool) { print("移動しました") } 上記のコードで行うと、警告が出ます。起動はできますが、コンソールに表示されません。 そこで以下のコードに変更するとコンソールにも表示されるようになりました。 func mapView(_: MKMapView, regionDidChangeAnimated animated: Bool) { print("移動しました") } ②マップ移動先中心点の座標をコンソールに表示させる(やりたいこと) func mapView(_: MKMapView, regionDidChangeAnimated animated: Bool) { let currentLocation = mapView.centerCoordinate print(currentLocation) } このコードで行うと起動はできますが、座標は表示できません。 また"_" → "mapView"に直して走らせると起動後、すぐ落ちます。 ### 補足情報(FW/ツールのバージョンなど)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。