UIScrollView contentSize not working

前端 未结 15 1609
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 06:18

I put a UIScrollView in my nib\'s view, and linked it to a an IBOutlet property.

Now, when I do this in my viewDidLoad

15条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 06:52

    I could never get auto layout based on constraints to work. Since my view was already a subclass UIScrollView I solved it by overriding setContentView: and ignoring auto layouts zero height setContentSize: message.

    @interface MyView : UIScrollView {}
    @end
    
    @implementation MyView
    - (void)setContentSize:(CGSize)aSize {
        if (aSize.height > 0)
            [super setContentSize:aSize];
    }
    @end
    

提交回复
热议问题