私はの3種類のマップビュー "Standard"、 ".Hybrid"、 "Satellite"を切り替えることを目指しています。 ".addTarget"行に次のエラーが表示されます。UISegmentedControl Swiftのターゲットの割り当て3
"ソースファイル内のエディタのプレースホルダ"
let segmentedControl = UISegmentedControl(items: ["Standard", "Hybrid", "Satellite"])
segmentedControl.backgroundColor = UIColor.white.withAlphaComponent(0.5)
segmentedControl.selectedSegmentIndex = 0
// EVENT LISTENER FOR SEGMENT CONTROL
segmentedControl.addTarget(self, action: "mapTypeChanged:", for: .valueChanged)
func mapTypeChanged(segControl: UISegmentedControl){
switch segControl.selectedSegmentIndex{
case 0:
mapView.mapType = .standard
case 1:
mapView.mapType = .hybrid
case 2:
mapView.mapType = .satellite
default:
break
}
}
私は新しいエラーメッセージが出ます: – dave
「ローカル変数の使用 『をmapTypeChanged』は、その宣言の前に、」あなたはこのコードを挿入している – dave
? ViewControllerの中に? –