UIScrollView doesn't scroll after upgrading to iOS7 / xcode 5

Tobias Lindgreen picture Tobias Lindgreen · Sep 11, 2013 · Viewed 27.9k times · Source

I have an app which in xcode 4.5 and ios 6.1 worked perfectly fine when scrolling. However, after downloading xcode 5 and iOS 7 my scroll views does not work anymore.???

Here is my .h file:

#import <UIKit/UIKit.h>

@interface GrillretterViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIScrollView *grillretterScroller;
@property (assign) CGPoint rememberContentOffset;

@end

And here is my .m file:

#import "GrillretterViewController.h"

@interface GrillretterViewController ()

@end

@implementation GrillretterViewController
@synthesize grillretterScroller, rememberContentOffset;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [grillretterScroller setScrollEnabled:YES];

    // Do any additional setup after loading the view.
}

- (void) viewDidAppear:(BOOL)animated {
    [grillretterScroller setContentSize:CGSizeMake(300, 915)];

}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    self.grillretterScroller.contentOffset = CGPointMake(0, 0);
}

- (void)viewWillDisappear:(BOOL)animated {
    self.rememberContentOffset = self.grillretterScroller.contentOffset;
    [super viewWillDisappear:animated];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    self.grillretterScroller.contentOffset = CGPointMake(0, self.rememberContentOffset.y);
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

PLEASE help! I'm stuck!

Best regards!

Answer

Jim Holland picture Jim Holland · Sep 20, 2013

I solved this by deselecting 'Use Autolayout' in the File Inspector pane of main view within the Scroll View.

enter image description hereenter image description here

If you want to keep 'Autolayout' enabled, try 'Editor -> Reslove Autolayout Issues -> Add Missing Constraints'. The key constraint appears to be 'Bottom Space to: Superview and in my case was -300, giving 300 scroll space on the botton of the view.