iOS: how to change the size of the UIScrollView content?

后端 未结 3 801
心在旅途
心在旅途 2021-02-06 13:00

I\'m now trying to create my own Text panel (with code highlighting and so on).

In fact everything is ready except one thing - scrolling

What I\'ve done: created

3条回答
  •  灰色年华
    2021-02-06 13:39

    Set your text field autoresizingMask property to flexible height and width:

    [textField setAutoResizingMask:UIViewAutoResizingFlexibleHeight | UIViewAutoResizingFlexibleWidth];
    

    This should expand the view automatically when you change it's parent's size (the scrollView's contentSize)

    Otherwise try:

    [textField setFrame:CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height)];
    

    just after you change the scroll view's contentsize.

提交回复
热议问题