Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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!

like image 226
Tobias Lindgreen Avatar asked Sep 11 '13 21:09

Tobias Lindgreen


1 Answers

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.

like image 171
Jim Holland Avatar answered Sep 28 '22 06:09

Jim Holland