2

I'm having an odd problem. I have a UIScrollView in a part of view hierarchy. It's working just fine when the view is presented via UITabBarController, but doesn't work at all after it is pushed with a Navigation controller (it is the third vc pushed atop the root). The scroll view was created in storyboard and the following lines are in the viewDidAppear method:

[super viewDidAppear:animated];
[self.scrollView setScrollEnabled:YES];
self.scrollView.contentSize = CGSizeMake(320.0f, 468.0f);

Any ideas, or suggestions? If you need shots of scrollview attributes inspector let me know. Here's the call method. The error might be somewhere inside here.

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main_iPhone"
                                                 bundle:nil];
    MKontaktViewController *vc = [sb instantiateViewControllerWithIdentifier:@"Kontakt"];
    vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self.navigationController pushViewController:vc
                                         animated:YES];

Thanks, Churchill

Churchill
  • 53
  • 8

2 Answers2

2

If you resize the scroll view content size in the viewDidLayoutSubview function it will work again.

- (void) viewDidLayoutSubviews {
    [self resizeScrollViewContent];
}

and
here same question

Community
  • 1
  • 1
  • What do I have to import or set delegate to use resizeScrollViewContent? – Churchill Apr 03 '14 at 08:54
  • @Churchill resizeScrollViewContent is a made up method that should contain the resizing code. you can instead just write self.scrollView.contentSize = CGSizeMake(1234, 5678); I just had this problem and this solves it. You should accept it as the correct answer! – maltalef May 09 '14 at 01:20
  • mitul marsonia's answer combined with what figha said works now. As does the following line of code: - (void) viewDidLayoutSubviews { self.scrollView.contentSize = CGSizeMake(1234, 5678); } – Churchill May 10 '14 at 05:48
1

I've solved this problem, but forgot to post it...

    - (void) viewDidLayoutSubviews 
    {
        [self resizeScrollViewContent];
    }

    - (void) resizeScrollViewContent
    {
        self.scrollView.contentSize = CGSizeMake(320.0f, 468.0f);
    }

Or you could use this as well:

    - (void) viewDidLayoutSubviews 
    {
        self.scrollView.contentSize = CGSizeMake(320.0f, 468.0f);
    }
Churchill
  • 53
  • 8