0

So me and my buddy have been working on an app. We have an ImageView embedded inside a ScrollView. It worked on iOS 5, but now we are updating it to iOS 7. We now have to use autolayout to make it look the app look nice again. But this disables scrolling it. We've attempted for a while to add code that allows the image to be scrollable again but nothing has helped.

We've tried everything under the sun we could find dealing with viewDidLoad (where we were originally doing it for iOS 5) and viewDidAppear (What we added to conform to iOS 7 and better practicality standards). Any suggests would be appreciated, we've exhausted every attempt.

@property (weak, nonatomic) IBOutlet UIScrollView *Scroll;
@property (weak, nonatomic) IBOutlet UIImageView *Image;

...

- (void)viewDidLoad
{
    [super viewDidLoad];

    // This is what we did for iOS 5
    //self.Scroll.contentSize = self.Image.image.size;
    //self.Image.frame = CGRectMake(0, 0, self.Image.image.size.width, self.Image.image.size.height);
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    //One of the many NEW attempts for iOS 7
    self.Scroll.contentSize = CGSizeMake(self.Image.image.size.width,self.Image.image.size.height);
}
Ion
  • 334
  • 3
  • 15

1 Answers1

1

You likely have your constraints assigned incorrectly.

I was able to get it to work with the constraints:

NSDictionary *bindings = @{@"imageView": self.Image};
[self.Scroll addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[imageView]|" options:0 metrics:0 views:bindings]];
[self.myScrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[imageView]|" options:0 metrics:0 views:bindings]];

See also: https://stackoverflow.com/a/13548039/580291 and as that points out: https://developer.apple.com/library/ios/releasenotes/General/RN-iOSSDK-6_0/index.html (search for scrollview)

Community
  • 1
  • 1
benuuu
  • 761
  • 2
  • 7
  • 24
  • We didn't have to deal with constraints in iOS 5, how do we know if we assigned them correctly/incorrectly? – Ion Oct 06 '13 at 03:59
  • I would recommend learning about autolayout from the wwdc videos. – benuuu Oct 06 '13 at 06:54