0

There is a view1(UIView) in Custom UITableViewCell in I need new size of view1(UIView) after AutoLayout

UITableViewCell content is dynamic, hence I used UITableViewAutomaticDimension for self resizing

I also use below methods but I get Original Size. I can not get new size of view1(UIView) after expanding

[self.tblView1 setNeedsLayout];
[self.tblView1 layoutIfNeeded];
[cell.contentView setNeedsLayout];
[cell.contentView layoutIfNeeded];   
[cell.view1 setNeedsLayout];
[cell.view1 layoutIfNeeded];
someengr
  • 690
  • 4
  • 18
Ankur Patel
  • 477
  • 5
  • 19
  • UITableViewAutomaticDimension gives dynamic cell size not dynamic view size. – Tushar Sharma May 16 '17 at 12:55
  • Follow this answer this will help you http://stackoverflow.com/a/43999765/1679754 – Jignesh Mayani May 16 '17 at 13:04
  • @TusharSharma JigneshMayani Yes UITableViewAutomaticDimension gives dynamic cell size. But how I get new size of UIView. My cell successfully expand and decrease according to content. Actually I want to draw Left Right Lower Border for UIView. but border draw according to its original size not according to New size of UIView – Ankur Patel May 16 '17 at 13:06
  • CALayer *leftBorder = [CALayer layer]; leftBorder.backgroundColor = [[HexToRGBColor colorFromHexString:[dictTblData objectForKey:@"cd_color"] alpha:1] CGColor]; leftBorder.frame = CGRectMake(0, 0, 3, cell.viewContent.frame.size.height); [cell.viewContent.layer addSublayer:leftBorder]; – Ankur Patel May 16 '17 at 13:07
  • Where did you added this code? add above code in layoutSubview() – karthikeyan May 16 '17 at 13:10
  • @karthikeyan How I add this code in layoutSubview()? because this is code of Custom UITableViewCell – Ankur Patel May 16 '17 at 13:13
  • Override layoutSubview it in your custom cell file – karthikeyan May 16 '17 at 13:14
  • @karthikeyan I added layoutSubview() this method to CustomCell File but there is no effect and control also do not reach to layoutSubview() method – Ankur Patel May 16 '17 at 13:24
  • @karthikeyan My cell successfully expand and decrease according to content. Actually I want to draw Left Right Lower Border for UIView. but border draw according to its original size not according to New size of UIView I added layoutSubview() in CustomCell.m but there is no effect – Ankur Patel May 16 '17 at 14:00
  • What are your constraints? – koen May 16 '17 at 16:56
  • @Koen constraints related superview top,left,right 10Px margin Bottom side 0 margin all 4 constraints related to SuperView in UITableViewcell – Ankur Patel May 17 '17 at 04:11
  • Have a look at this: http://stackoverflow.com/questions/18746929/ – koen May 17 '17 at 11:32

0 Answers0