Calculate the contentsize of scrollview

前端 未结 7 1474
旧巷少年郎
旧巷少年郎 2020-12-13 11:40

I\'m having a scrollview as the detailedview of tableview cell. There are multiple views on the detailedview like labels, buttons etc. which I\'m creating through interface

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 12:16

    A somewhat easier way to do this is to nest your layout within a view then put that view within the scrollview. Assuming you use tags, this works as follows:

    UIScrollView *scrollview = (UIScrollView *)[self.view viewWithTag:1];
    UIView *longView = (UIView *)[self.view viewWithTag:2];
    scrollview.contentSize = CGSizeMake(scrollView.frame.size.width, longView.frame.size.height);
    

    That way the longView knows how tall it is, and the scrollview's content is just set to match.

提交回复
热议问题