2016-06-24 5 views
0

xbu에서 사용자 정의보기로드를 UIImage으로 변환하여 마커 icon.it로 표시하고 있습니다.하지만이 작업을 수행하면 for 루프에서 100 개의 마커가 표시 될 수 있습니다. 그것은 xib 사용자 정의보기를로드하기 때문입니까? 아래 사용자 정의 Google지도 아이콘 아이콘 이미지

함수가 루프에서 호출되는

func generateSpot(Prop: Property) -> Spot { 

    let latStr = Prop.propLat 
    let langStr = Prop.propLang as NSString 
    let langDbl : Double = Double(langStr.floatValue) 
    let latDbl : Double = Double(latStr.floatValue) 

    let marker:GMSMarker = GMSMarker() 
    marker.position = CLLocationCoordinate2DMake(langDbl,latDbl) 
    marker.appearAnimation = kGMSMarkerAnimationPop 
    marker.title = Prop.propBuildingName as String 
    marker.snippet = Prop.propCode as String 
    marker.infoWindowAnchor = CGPointMake(0.44, 0.45) 

    let sizeVar:CGSize = CGSize(width: 41, height: 37) 

    let customeMarker :CustomMarker = NSBundle.mainBundle().loadNibNamed("CustomView", owner: self.view, options: nil).first! as! CustomMarker 

    customeMarker.frame = CGRectMake(customeMarker.frame.minX,customeMarker.frame.minY,customeMarker.frame.width,customeMarker.frame.height) 
    customeMarker.mappedNumbers.layer.masksToBounds = true 
    customeMarker.mappedNumbers.layer.cornerRadius = 8 
    customeMarker.mappedNumbers.text = Prop.propSequence as String 

    if Prop.propStatus == self.constants!.status.STATUS_COMPLETED_XML 
    { 
     customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0x70b420) 
     customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0x70b420) 
    } 

    if Prop.propStatus == self.constants!.status.STATUS_DRAFT_XML 
    { 
     customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0xd2cb46) 
     customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0x70b420) 


    } 
    if Prop.propStatus == self.constants!.status.STATUS_PENDING_XML 
    { 
     customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0xd44646) 
     customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0xd44646) 


    } 


    UIGraphicsBeginImageContextWithOptions(sizeVar, false, 0) 
    customeMarker.drawViewHierarchyInRect(customeMarker.bounds, afterScreenUpdates: true) 

    let newImage = UIGraphicsGetImageFromCurrentImageContext() 
    UIGraphicsEndImageContext() 
    marker.icon = newImage 
    marker.map = self.googleMapView 
    let spotObje:Spot = Spot() 
    spotObje.location = marker.position 
    spotObje.marker = marker 
    return spotObje 
} 
+0

는이를 다시 수행 지상 스레드 – Shubhank

+0

백그라운드 스레드에서 시도했지만 오류가 발생합니다.이 응용 프로그램은 백그라운드 스레드에서 autolayout 엔진을 수정하여 엔진 손상 및 이상한 충돌을 일으킬 수 있습니다. 이로 인해 향후 릴리스에서 예외가 발생합니다. –

+0

업데이트 된 코드를 별도의 http://gist.github.com 링크에 표시하십시오. – Shubhank

답변

관련 문제