2016-06-26 3 views
0

나는 하나의 뷰에 tableview와 apple 맵을 섞어서 tableview 셀을 선택하면 관련 주석을 선택할 수 있기를 바랍니다. 여기스위프트 믹스 tableviewcell 및지도, tableview 셀을 선택하고 주석도 선택하십시오

은 내가 그것을 할 방법 :

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){ 

    var selectedCell:UITableViewCell 
    selectedCell = tableView.cellForRowAtIndexPath(indexPath)! 
    self.mapView.selectAnnotation(self.mapView.annotations[indexPath.row], animated: true) 
    mapTableView.reloadData() 

     } 

을하지만 셀을 선택하면 unrelate 주석은 또한 주석도 userLocation를 포함, 어떻게 주석의를 만들기 위해이 문제를 해결할 수 있기 때문에 그게 전부 가정 selected.I 수 tableview cell indexpath.row의 순서와 같은 순서? 또한 선택된 주석으로 중심을 이동합니까? 답장을 보내 주셔서 감사합니다!

답변

0

스패이스 효과를 사용하여 간단하게 가난한 사람들을 쉽게 얻을 수 있습니다.

코드가 여기에 표시되면 누군가가 이런 종류의 효과를 내고 싶어합니다.

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){ 
    //not finished yet 
    var selectedCell:UITableViewCell 
    selectedCell = tableView.cellForRowAtIndexPath(indexPath)! 
    var location = tripspots[indexPath.row].coordinate 
    //resolution 
    var span = MKCoordinateSpanMake(0.01, 0.01) 
    var region = MKCoordinateRegion(center: location,span:span) 
    //move to the specific area! 
    self.mapView.setRegion(region, animated: true) 
    mapTableView.reloadData() 
} 
관련 문제