iphone - Unadded MKMapView renderInContext problems -
i trying image out of mkmapview add "thumbnail" image uitableviewcell. problem image renders solid color , not correct map. have added mkmapview straight view test purposes , loads correctly.
here code cellforrowatindexpath:
//create correct map thumbnail mkmapview *mapforthumbnail = [[mkmapview alloc] init]; mapforthumbnail.frame = cgrectmake(0, 0, 100, 100); mapforthumbnail.delegate = self; cllocationcoordinate2d coords[coordinates.count]; for(int = 0; < coordinates.count; i++){ cllocation *currentlocationcoords = [coordinates objectatindex:i]; coords[i] = cllocationcoordinate2dmake(currentlocationcoords.coordinate.latitude, currentlocationcoords.coordinate.longitude); }//end mkpolyline *polylineformapthumbnail = [mkpolyline polylinewithcoordinates:coords count:coordinates.count]; [mapforthumbnail addoverlay:polylineformapthumbnail]; [mapforthumbnail setregion:mkcoordinateregionformaprect([polylineformapthumbnail boundingmaprect])]; uigraphicsbeginimagecontextwithoptions(cgsizemake(100, 100), no, 0.0); cgcontextref currentcontext = uigraphicsgetcurrentcontext(); [mapforthumbnail.layer renderincontext:currentcontext]; uiimage *mapimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); cell.imageview.image = mapimage; cell.detailtextlabel.text = stringfordetaillabel; cell.detailtextlabel.font = [uifont fontwithname:@"verdana" size:12.0f]; cell.detailtextlabel.textcolor = [uicolor darkgraycolor];
here image of whats happening:
Comments
Post a Comment