iphone - crash at drawInRect:rect, I've the solution but don't know how? -
the app works fine iphone simulator when run in actual iphone device crashes @ following line:
[ucdview.image drawinrect:rect];
i've searched , found solution don't know how solve time short when have present on friday. @ following solution: must drawinrect: separate context executed on main thread?
the part crash happen in sculpture.m inside viewdidload()
- (void)viewdidload{ [super viewdidload]; clcontroller = [[corelocationcontroller alloc] init]; clcontroller.delegate = self; [clcontroller.locmgr startupdatinglocation]; currentloc = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"redpin.png"]]; uiimage *ucdimage = [uiimage imagenamed:@"ucd.png"]; self.ucdview = [[uiimageview alloc] initwithimage:ucdimage];//creating view ucd image ucdview.userinteractionenabled = yes; [self loadingfile]; uiscrollview *myscrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; [myscrollview setminimumzoomscale:0.35]; [myscrollview setmaximumzoomscale:2.0]; myscrollview.clipstobounds = yes; myscrollview.bounces = yes; myscrollview.contentoffset = cgpointmake(1400, 700); [myscrollview setcontentsize:cgsizemake(ucdimage.size.width, ucdimage.size.height)]; [myscrollview setdelegate:self]; [myscrollview addsubview:ucdview];//adding ucd view scroll view [self.view addsubview:myscrollview]; // adding scrollview self.view main view [myscrollview release]; //drawing line uigraphicsbeginimagecontext(ucdview.frame.size); cgrect rect = cgrectmake(0, 0, ucdview.frame.size.width, ucdview.frame.size.height); [ucdview.image drawinrect:rect]; cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetlinewidth(context, 3.0); cgcontextsetstrokecolorwithcolor(context, [uicolor bluecolor].cgcolor); cgfloat dasharray[] = {2,0,2,2}; cgcontextsetlinedash(context, 3, dasharray, 5); cgcontextmovetopoint(context,[self longt_to_x:[[path_array objectatindex:0] doublevalue]],[self lat_to_y:[[path_array objectatindex:1] doublevalue]]); int path_length = [path_array count]; for(int = 2; i<path_length; = i+2){ cgcontextaddlinetopoint(context,[self longt_to_x:[[path_array objectatindex:i] doublevalue]],[self lat_to_y:[[path_array objectatindex:i+1] doublevalue]]); } cgcontextstrokepath(context); ucdview.image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();
}
thanks million in advance...
you didn't crash was, have created 1 image context uigraphicsbeginimagecontext
, , create 1 cgbitmapcontextcreate
. guess later 1 problem (getting arguments right can tricky) , isn't want anyway. change to:
// current drawing context image context right cgcontextref context = uigraphicsgetcurrentcontext();
Comments
Post a Comment