Can someone PLEASE help me out here. I've been scouring the internet for 2 days now looking for ways on how to do this. It seems like it should be simple enough, but it's not.
Just like many others, I'm following along the Stanford iOS 5 tutorials and got to Lecture 8: Controller Lifecycle & Image/Scroll/WebViews. I know in this example, he's using springs and struts, but I'd like to see it get done just as easily in iOS 6.
So, in iOS 5, we just set the contentSize of our UIScrollView = to the size of our UIImageView. However, in iOS 6, we're told NOT to set contentSize.
So, I start off with a new project, drag in the UIImageView, embed it into a UIScrollView. I make sure that Auto Layout is enabled. I create outlets in my view controller for both the scroll view and the image view, then I look to my constraints. This is where I get stuck.
With how great everyone says the new constraints are, I can't believe that something as simple as this can't be so straight forward. I've gone through all my constraints. I've made sure that they're all adequate, yet when I run my app, the scroll view doesn't pan the image.
Now, if I implement the following:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.scrollView removeConstraints:self.scrollView.constraints];
[self.imageView removeConstraints:self.imageView.constraints];
NSDictionary *viewsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:self.scrollView, @"sv", self.imageView, @"iv", nil];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[sv]|" options:0 metrics:nil views:viewsDictionary]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[sv]|" options:0 metrics:nil views:viewsDictionary]];
[self.scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[iv]|" options:0 metrics:nil views:viewsDictionary]];
[self.scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[iv]|" options:0 metrics:nil views:viewsDictionary]];
}
It works fine, but look at the constraints I set up. It's not like they're complicated. So why can't this be done easily in IB (at least not from everything I've tried)?
If this CAN be done in IB, can someone please show me how?!?!