I have a problem with autolayout(maybe) and my scrollview!
My Problem
2.Then I push to another View
3.Then I go back and the scrollview looks like that and I'm not able to scroll to the highest point.(I see it in the bouncing of the scrollview)
Can anybody help me?
Auto Layout constraints allow us to create views that dynamically adjust to different size classes and positions. The constraints will make sure that your views adjust to any size changes without having to manually update frames or positions.
Auto Layout defines your user interface using a series of constraints. Constraints typically represent a relationship between two views. Auto Layout then calculates the size and location of each view based on these constraints. This produces layouts that dynamically respond to both internal and external changes.
The following code snippet in the containing view controller also seems to solve the problem, without relying on explicit sizes:
- (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; self.mainScrollView.contentOffset = CGPointZero; }
It does reset the content offset to the origin, but it seems that so do the other answers.
if you are still searching for an answer i found it today after two days of headbanging the wall. I will just paste you the code, but the most important thing is when you load your scrollView..
-(void)viewWillAppear:(BOOL)animated{ [scrollView setFrame:CGRectMake(0, 0, 320, 800)]; } -(void)viewDidAppear:(BOOL)animated { [scrollView setScrollEnabled:YES]; [scrollView setContentSize:CGSizeMake(320, 800)]; }
all this is loaded before -(void)viewDidLoad
notice the height is in both instances 800, which is crucial for resolving this problem. good luck with your project ;)
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