ios - How to add custom UIView(xib) in custom UITableviewCell with the help of AutoLayout? -


i have 1 view controller in have 1 uitableview.

i have used custom uitableviewcell xib in uitableview.

now have 1 uiview xib , want add uiview's object in custom uitableviewcell of autolayout.

i added uiview in custom uitableviewcell, uiview big , it not fitting in custom uitableviewcell.

i know uiview can fit in custom uitableviewcell of autolayout, don't know how, because new autolayout.

in custom uitableviewcell

customalertcell.m//this custom uitableviewcell class  -(void)addcustomview_forrow:(int)therow {     jobalertcell_view *vwjob = [[jobalertcell_view alloc] initfromnibfile:@"jobalertcell_view"];    vwjob.frame = cgrectmake(0, 118, vwjob.frame.size.width, vwjob.frame.size.height);    [self addsubview:vwjob]; } 

here vwjob.frame.size.height = 90, in device bigger size want.

thanks.

you can add width , height constraint using below code

    -(void)addcustomview_forrow:(int)therow     {        jobalertcell_view *vwjob = [[jobalertcell_view alloc] initfromnibfile:@"jobalertcell_view"];        [self addsubview:vwjob];          [self addconstraint:[nslayoutconstraint constraintwithitem:vwjob                                                        attribute:nslayoutattributeheight                                                        relatedby:nslayoutrelationequal                                                           toitem:nil                                                        attribute:nslayoutattributenotanattribute                                                       multiplier:1.0                                                         constant:100.0]];         [self addconstraint:[nslayoutconstraint constraintwithitem:vwjob                                                        attribute:nslayoutattributewidth                                                        relatedby:nslayoutrelationequal                                                           toitem:nil                                                        attribute:nslayoutattributenotanattribute                                                       multiplier:1.0                                                         constant:100.0]];         [self layoutifneeded];      } 

source:

https://codehappily.wordpress.com/2013/09/21/constant-height-width-constraint-autolayout/ https://codehappily.wordpress.com/2013/10/09/ios-how-to-programmatically-add-auto-layout-constraints-for-a-view-that-will-fit-its-superview/

hope helps you...!


Comments