cocoa - Layout subviews in TableViewCell without adding to NSTableView -


i have subclass of nstableviewcell has several controls in it, , need width of 1 of them calculate height row.

since not allowed cell tableview:heightofrow, need calculate height taking account width of textfield thats inside cell , string goes in row.

i figured i'd create single static cell, give frame current width , make calculate , perform layout , resulting width textfield width.

here code thats supposed me width of "nametextfield"

    +(float)nametextfieldwidthfortasktabletype:(tasktabletype )type compactsize:(bool)compactsize totalcellwidth:(float)totalwidth{     static taskcellview *taskcell = nil;     if (taskcell == nil) {         taskcell = [[taskcellview alloc]initwithcompactsize:compactsize tasktabletype:type identifier:@"notused"];     }      if (taskcell.frame.size.width != totalwidth) {         taskcell.frame = nsmakerect(0, 0, totalwidth, 25);         [taskcell updateconstraints];      }      nstextfield *nametextfield = [taskcell viewforcomponent:ktaskcellcomponentname];     return nametextfield.frame.size.width;  } 

the cell subviews constraint based. , work ok. here, nametextfield frame zero. cell need superview layout ? or else missing ?

this did trick:

   [taskcell layoutsubtreeifneeded]; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -