Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple vertically scrolling UIScrollViews in a horizontal UIScrollView

Tags:

ios

ios5

I'm developing an app, where I have one horizontally scrollable UIScrollView fullscreen with pagination that contains multiple (let's say 3) vertically scrollable UIScrollViews, each also fullscreen. They're positioned without margins, the left ones origin is (0,0).

Each vertically scrollable UIScrollView consists of buttons placed one above the other, each when clicked, presents a ViewController:

[self presentViewController:someViewController animated:YES completion:nil];

Now this code works fine for the two right UIScrollViews, but it's buggy for the left one:

  • The buttons bellow the height of the horizontal UIScrollView are not clickable. So if the height of the horizontal UIScrollView is 440px, any UIButton with origin.y > 440 is uncklickable.
  • If the UIScrollView is slightly scrolled down and a button is clicked (that is not below 440px), the whole UIScrollView gets "moved" down and gets sorta laggy while the requested view controller gets presented. When this view controller gets dismissed, the scroll view stays lower. If I scroll it back up and press a button, it magically jumps up to where it should be.

Now for the fun part!

If I change the origin of the left UIScrollView to (1,0), this issue dissapears! What could be making this problem?

Some added code:

[horizontalSV setDelegate:self];
[horizontalSV setContentSize:horizontalContentView.frame.size];
[horizontalSV addSubview:horizontalContentView];                  // View containing vertical scroll views, it's set up in IB
[horizontalContentView setFrame:CGRectMake(-1, 0, 961, 440)];     // This is now used for the hack

// Now imagine three of these
firstSVcontent = [[VerticalContentView alloc] init];              // Setting the content view
[firstSVcontent setTitle:title];
[firstSVcontent setButtons:blahblah];
[firstVerticalSV setContentSize:firstSVcontent.view.frame.size];  // Setting vertical scroll view
[firstVerticalSV addSubview:firstSVcontent.view];
like image 711
Gasper Avatar asked Mar 09 '26 11:03

Gasper


1 Answers

I've resolved this issue almost a year later!

The problem was, I was doing most of my view managment in a XIB file and then I just read those content views and scroll views in my viewDidLoad method and put them together.

Now I've rewritten my code to create all scroll views and content views programatically and everything works without a problem.

like image 75
Gasper Avatar answered Mar 11 '26 02:03

Gasper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!