ios - Dynamically changing the height of the cell and UIImage based on the ratio of actual image -


this have tried far

i defined global variable

float imgheight; 

then in - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath this

        size_t pixelswide = cgimagegetwidth(scribbleimage.image.cgimage);         size_t pixelshigh = cgimagegetheight(scribbleimage.image.cgimage);         cgfloat ratio = 312/pixelswide;         pixelshigh = pixelshigh*ratio; 

then in - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath

return pixlesheight; 

now since heightforrowatindexpath called before cellforrowatindexpath, pixelsheight 0.

i cannot figure out way of doing this. should redefine uiimage in heightforrow , this

[scribbleimage setimagewithurl: [nsurl urlwithstring:scribble[@"scribble_image"]] placeholderimage:[uiimage imagenamed:@"default.png"]]; 

in there well?! there should easier way of doing this.

do in heightforrowatindexpath. understand concerns wasting processing , loading time, store uiimage within array of items once processed in order use same 1 in cellforrowatindexpath, avoiding create new 1 then.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -