I'm trying to force the content size of my UIScrollVIew
when it's container loads. I'm finding this much more difficult than I'd imagine it would be. I've tried setting the content size in both viewDidLoad
and viewWillAppear
, like so:
-(void)viewWillAppear:(BOOL)animated
{
CGSize newContentSize = CGSizeMake(scrollView.contentSize.width, scrollView.frame.size.height + 80.0);
[scrollView setContentSize:newContentSize];
}
If I place a breakpoint right after I call setContentSize
, I can see that the new content size is indeed what I set it to.
However, if I then check the content size at some arbitrary point after viewWillAppear
, such as, say, scrollViewDidScroll
, the content size has reverted back to the size of the "actual" content in the scroll view, and not the size I tried forcing it to be in viewDidAppear
.
Why is this?
I have no idea what is resetting it on you, but I can help you find the answer.
What I usually do in a situation like this is subclass UIScrollView (usually as "XXXUIScrollView"), override setContentSize:
(to just call [super setContentSize:size]
, maybe with an NSLog), and set a breakpoint in the overridden method to see what is setting the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With