简体   繁体   中英

View's correct width in XIB?

I have a custom XIB view and a scrollview in it. Is there a way to access the scrollview's width during runtime from the XIB's UIView class.

As this is not a view controller I do not have access to viewDidLayoutSubviews.

scrollView.frame.size.width

returns the default width from the Interface Builder

I found out a simple hack that works.

The trick is to override layoutSubviews and then get the value of frame there.

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