私はmapviewでテーブルビューではなく作業していますが、indexPath.rowの代わりに何を使うべきかわかりません。indexPath.rowの代わりに何を使用しますか?非テーブルのために?
注釈の情報ボタンが押されると、注釈付きのマップビューが表示されます。次に、CKデータベースに照会し、押された注釈の名前と一致する名前フィールドを持つレコードを返します。これは、一致する名前がないので、単一レコードの[CKRecord]を返します。私はデータにアクセスするには、次のだろうテーブルビューで、この時点で
、...
let placeInfo = selectedData[indexPath.row]
let placeName = placeInfo.objectForKey("Name") as! String
let placeCity = placeInfo.objectForKey("City") as! String
しかし、私はテーブルビューを使用していないことから、私が使用するindexPathを持っていません。私の[CKRecord]オブジェクトは、単一のレコードが含まれているので、私はラインが範囲エラー外のインデックスを生成すること
let placeInfo = selectedPlace[0] //also tried 1
...私は、レコードのアレイ位置でindexPath.rowを置き換えることができると思いました。
私が知っていることをすべて試しましたが、あなたが想像しているように、私はこの時点で、一般的なプログラミングや迅速な開発にはまったく適していません。ここで
は、私が使用していますフルのMapView機能です...
func mapView(mapView: MKMapView, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
let cloudContainer = CKContainer.defaultContainer()
let publicData = cloudContainer.publicCloudDatabase
let tappedPlace = annotationView.annotation!.title!! as String
let predi = NSPredicate(format: "Name = %@", tappedPlace)
let iquery = CKQuery(recordType: "Locations", predicate: predi)
publicData.performQuery(iquery, inZoneWithID: nil, completionHandler: {
(results, error) -> Void in
if error != nil {
print(error)
return
}
if let results = results {
print("Downloaded data for selected location for \(tappedPlace)")
NSOperationQueue.mainQueue().addOperationWithBlock() {
self.selectedPlace = results
}
}
})
let placeInfo = selectedPlace[0]
let placeName = placeInfo.objectForKey("Name") as! String
//returns Index out of range error for placeInfo line
//need data before segue
//performSegueWithIdentifier("fromMap", sender: self)
}
うん、それを修正!本当にありがとう! – ALTVisual