mapView가있는 Xcode 프로젝트가 있습니다. 이 배열에서 내 친구 (Kevin)를로드합니다.Xib 이미지 요소를 채울 때 Swift MapView가 최신 시프트를 유지하지 않습니다.
myProfiles.append(UserClass
(locationLatitude:44.067, locationLongitude:-88.296,
id:1,username: "Kevin"
)
)
지도에 내 친구를 표시하는 customAnnotation이 있습니다. 내 친구 주석은지도의 맨 아래에 있습니다. 따라서 주석을 클릭하면 mapView가 203 칸만큼 위로 밀고 거기에 머물러 있어야합니다.
// triggered when the user selects an annotation. We are clicking on Kevin
func mapView(_ mapView: MKMapView, didSelect annotationView: MKAnnotationView)
{
print("before setting map")
let adjustedBy: CGFloat = 203.0
self.mapView.frame.origin.y = self.mapView.frame.origin.y - adjustedBy
self.populateSelectedProfile()
}
func populateSelectedProfile() {
DispatchQueue.main.async {
// the tag 1000 is for the first user in array (username: Kevin)
if let userXib = self.view.viewWithTag(1000) as? User {
print("setting up user")
userXib.isHidden = false
userXib.userImageView.image = UIImage(named: "user")
}
}
}
populateSelectedProfile은 (이미지 뷰는 빌더에서 만든) 친구의 이미지로 XIB를 채우기 시작합니다 :
@IBOutlet weak var userImageView: UIImageView!
을하지만 발생하면 상단에 밀어 후지도, 그것은가는 것입니다 이미지 뷰를 채우고 바로 아래로. 인쇄 줄에 중단 점을 배치하면이 동작을 볼 수 있습니다.
print("setting up user")
왜 mapView가 다시 아래로 이동합니까?
참고 : 이미지를 표시하는 데 신경 쓰지 않습니다. 나는 그것을하는 방법을 안다. 내 문제는 mapView 다시 내려 오는 것입니다.