2016-11-30 9 views
1

안녕하세요 여러분의 주석의 핀을 맞춤 이미지로 바꾸려고합니다.pin 대신 annotation에 이미지를 할당

이미지에 이미 이미지가 있습니다. 카세트 목록에 1X 2X 3X 등이 표시되지만 이미지를 호출하자마자 Xcode은 내 구문을 수정하려고 시도하지만 결국에는 오류가 발생합니다. 초과 오류로

재정의 FUNC 아래에 나열된

내 코드

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { 

    guard !(annotation is MKUserLocation) else { 
     return nil 
    } 


    let annotationIdentifier = "AnnotationIdentifier" 

    var annotationView: MKAnnotationView? 
    if let dequeuedAnnotationView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationIdentifier) { 
     annotationView = dequeuedAnnotationView 
     annotationView?.annotation = annotation 
    } 
    else { 
     annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier) 
     annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) 
    } 

    if let annotationView = annotationView { 

     annotationView.canShowCallout = true 
     annotationView.image = UIImage(named: "House") 
    } 

    return annotationView 
} 

이제 Xcode 코드 annotationView.image =있는 UIImage 여기에 오류를 따기입니다 (이름 : "집")가에 물어 곳 삽입 "," 그리고 최종 결과는 '집'

+0

오류가 무엇을 말하는가를 중심으로되지 않는 문제가? – GeneCode

+0

미해결 식별자 '하우스'사용 – sabrefm1

답변

0

스위프트 (3) 이미지 리터럴을 소개 해결되지 않은 식별자 오류 사용을 표시이

annotationView.image = UIImage(named: "#imageLiteral(resourceName: ",House,")") 

Xcode 것 같습니다. "Imag"라고 쓰면 이미지 리터럴 옵션이있는 팝업 창이 열립니다. 이미지 아래처럼 "이미지 리터럴"옵션을 선택하면

enter image description here

, 그것은 당신이 그리드에서 사용할

enter image description here

선택 이미지를 사용할 수있는 모든 자산 이미지가 팝업됩니다.

자세한 내용은

see this

0

이 코드는 내 문제

let pinImage = UIImage(named: "House.png") 
annotationView.image = pinImage 

을 고정 도움하지만 난 지금 내지도는 더 이상