ios - pickerView different row height -


i have pickerview data loaded website. want set height each row of pickerview.

here tried seems pickerview accept's 1 value rows.

func pickerview(pickerview: uipickerview, rowheightforcomponent component: int) -> cgfloat {     var height: cgfloat = 40     if categories.count != 0 {         return heightforview((categories[component].valueforkey("name") as? string)!, font: uifont(name: "helveticaneue-thin", size: pickerfontsize!)!, width: pickerview.frame.width) + 10     }     return height + 10 }  func heightforview(text: string, font: uifont, width: cgfloat) -> cgfloat {     let label:uilabel = uilabel(frame: cgrectmake(0, 0, width, cgfloat.max))     label.numberoflines = 0     label.linebreakmode = nslinebreakmode.bywordwrapping     label.font = font     label.textalignment = .center     label.text = text     label.sizetofit()     return label.frame.height } 

for first time categories array empty , rowheightforcomponent uses constant value. when load data core data want pickerview reload new componentheight doesn't called when wrote:

pickerview.reloadallcomponents() 

i've figured when call reloadallcomponents: of delegate/datasource methods called except rowheightforcomponent:

i found workaround should resolve problem. each time wish set height of rows calling reloadallcomponents:, reset delegate uipickerview. this:

pickerview.delegate = self pickerview.reloadallcomponents() 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -