简体   繁体   中英

How to get the real frame after autoresized an UIView

I have an UIView that is set to autoresize depending the partent view, The problem is that the frame returns the original size even when it is autoresized.

- (void)awakeFromNib{
       NSLog(@"%@", NSStringFromCGRect(self.frame));}

it is returns the original size!

You must use one of the viewController lifecycle function to get the real size of the subviews.

One of them will work:

  • viewDidLayoutSubviews
  • viewDidAppear

For more details check the answer of this question: Unable to set frame correctly before viewDidAppear

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM