iphone - UIImageView doesn't update -
i have problem uiimageview doesn't update. so, it's this: have uiscrollview contains uiimageview (called imageview). now, imageview , should contain more uiimageviews. uiimageviews add code not appear.
this code:
for(i = 0 ; < nroftilesperheight ; i++) for(j = 0 ; j < nroftilesperwidth ; j++) { imagerect = cgrectmake(j*tile_width,i*tile_height,tile_width, tile_height); image = cgimagecreatewithimageinrect(aux.cgimage, imagerect); if(!data[i][j]) nslog(@"data[%d][%d] nil",i,j); context = cgbitmapcontextcreate (data[i][j], tile_width, tile_height, bitspercomponent, bitmapbytesperrow, colorspace, kcgimagealphapremultipliedlast | kcgbitmapbyteorder32big); if (context == null) { free (data); printf ("context not created!"); cgcolorspacerelease( colorspace ); } cgcontextdrawimage(context, cgrectmake(0, 0, tile_width, tile_height), image); data[i][j] = cgbitmapcontextgetdata (context); memcpy(originaldata[i][j],data[i][j],tile_width*tile_height*numberofcompponents); cgcontextflush(context); cgimagerelease(image); uiimageview *imgview = [[uiimageview alloc] init]; [imgview settag:i*10+j]; cgrect frame = imgview.frame; frame.origin.x = j * (tile_width+5) * initialscale; frame.origin.y = * (tile_height+5) * initialscale; frame.size.width *= initialscale; frame.size.height *= initialscale; [imgview setframe:frame]; [imageview addsubview:imgview]; [self updatetileatline:i androw:j]; [imgview release]; cgdataproviderrelease(dataprovider); cgimagerelease(cgimage); } - (void) updatetileatline: (int) androw: (int) j { cgdataproviderref dataprovider = cgdataprovidercreatewithdata(null, data[i][j], bitmapbytecount, null); cgimageref cgimage = cgimagecreate(tile_width, tile_height, bitspercomponent, bitsperpixel, bitmapbytesperrow, colorspace, kcgimagealphapremultipliedlast | kcgbitmapbyteorder32big, dataprovider, null, false, kcgrenderingintentdefault); uiimage *myimg = [uiimage imagewithcgimage:cgimage]; uiimageview *auximageview = (uiimageview*) [imageview viewwithtag:(i*10+j)]; [auximageview setimage:myimg]; cgdataproviderrelease(dataprovider); cgimagerelease(cgimage); }
now...this doesn't crashes...so non-nil , ok. if instead of using viewwithtag , alloc init new uiimageview , add imageview, appear. don't want copy of view since updatetile method called quite often.
my question is: why doesn't auximageview appear? should.
thank you.
regards, george
try this
for(uiview *view in [imageview subviews]) { if(view.tag == i*10+j) { uiimageview *auximageview = (uiimageview*) view; [auximageview setimage:myimg]; } }
Comments
Post a Comment