2
votes

UPDATED -- I have an iPad app that was originally designed and written for portrait mode only; I now want to add a UIScrollView so it will scroll in landscape mode. Auto Layout is checked and the different scenes are built using Storyboard. (I am following this tutorial). The major problem is when switching from portrait to landscape, the bounds of the frame change drastically, thereby causing problems with the logic of the scroll.

This is the image of the first scene (UIView) I am trying to add a UIScrollView to: enter image description here

This is what it looks like in landscape mode (w/o scrolling): enter image description here

This is my code in the -viewDidLoad method for that scene:

//  create UIScrollView
UIScrollView *scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0,0,self.bookDetailView.frame.size.width, self.bookDetailView.frame.size.height)];
scroll.delegate = self;
scroll.pagingEnabled = YES;
scroll.scrollEnabled = YES;
scroll.showsVerticalScrollIndicator = YES;
CGSize scrollableSize = CGSizeMake(768, 1024);  //  size of portrait mode
scroll.contentSize = scrollableSize;

[self.view addSubview: scroll];

The scroll bar (as thin as it is) now shows, BUT although it moves like it should, the UIView doesn't move. Portrait mode works fine (no scrolling needed) but landscape mode doesn't scroll at all (even tho' the vertical scroll bar does move). I'm wondrering if I should abandon the idea of using scrolling for landscape mode and create separate scenes for landscape mode instead.

1
Have you set the contentSize of your UIScrollView?antonio081014
Hi, how are you adding the view to the UIScrollView? And, how are you setting up that view's autosizing/autolayout?Sheamus

1 Answers

4
votes

Is there any reason why you need a separate UIScrollView ? UITableView is already a scroll view. My guess is that the touch events from the UIScrollView you created are interfering with those of the UITableView.