Thursday 15 August 2013

c# - Align label in UITableViewCell on the right with Auto Layout -



c# - Align label in UITableViewCell on the right with Auto Layout -

i want utilize auto layout may table view cell content. worked far. want align uilabel on right side of table view. if this, isn't aligned right. instead on left side. seems width of table view not calculated when constraint applied. tried 2 different approaches:

no. 1:

this.contentview.addconstraints (nslayoutconstraint.fromvisualformat ("h:[inumberlabel]-|", (nslayoutformatoptions)0, null, viewsdictionary));

no. 2:

this.contentview.addconstraint (nslayoutconstraint.create (inumberlabel, nslayoutattribute.right, nslayoutrelation.equal, this.contentview, nslayoutattribute.right, 1, 0));

the constraints added in updateconstraints in table view cell subclass. code in c# doesn't matter. glad if provide solution.

this format string: "h:|-[inumberlabel]-|"

tells scheme pin label both sides of cell default padding, label width of cell. should rid of spacing left side, if want right aligned,

"h:[inumberlabel]-|"

i don't know why sec method didn't work. if that's horizontal constraint had, should have worked.

c# ios uitableview autolayout

No comments:

Post a Comment