// Create the scroll view and the image view. scrollView = [[UIScrollView alloc] init]; imageView = [[UIImageView alloc] init];
// Add an image to the image view. [imageView setImage:[UIImage imageNamed:"MyReallyBigImage"]]; // Add the scroll view to our view. [self.view addSubview:scrollView]; // Add the image view to the scroll view. [scrollView addSubview:imageView];
// Set the translatesAutoresizingMaskIntoConstraints to NO so that the views autoresizing mask is not translated into auto layout constraints. scrollView.translatesAutoresizingMaskIntoConstraints = NO; imageView.translatesAutoresizingMaskIntoConstraints = NO;
// Set the constraints for the scroll view and the image view. viewsDictionary = NSDictionaryOfVariableBindings(scrollView, imageView);