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 - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -