以下を実装する方法を探しています。
- 上部にフルスクリーン UIView とこの下にフルスクリーン UIScrollView の両方を含む 1 つの「マスター」scrollView を用意します。
- ユーザーが上部の UIView を超えてスクロールすると、下部の scrollView が表示され、スクロール イベントのレスポンダーになります。
- ユーザーが一番下の UIScrollView から上にスクロールしようとすると、タッチがリダイレクトされるため、「マスター」scrollView が制御され、UIView が再び表示されます。
これがどのように設定されているかを理解するために、現在の実装を次に示します。
// Initialise components:
mainScreen = [[UIScreen mainScreen] bounds];
CGFloat screenHeight = mainScreen.size.height-20;
// Scroll View Controller
_scrollControl = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, screenHeight)];
_scrollControl.contentSize = CGSizeMake(320, 2*screenHeight); // Twice as big as the screen size for both views to fit
_scrollControl.backgroundColor = [UIColor clearColor];
_scrollControl.delegate = self;
// Top View
_topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, screenHeight)];
_topView.backgroundColor = [UIColor redColor];
[_scrollControl addSubview:_topView];
// Bottom View
_bottomView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, screenHeight, 320, screenHeight)];
_bottomView.backgroundColor = [UIColor yellowColor];
_bottomView.contentSize = CGSizeMake(320, 2*screenHeight);
_bottomView.delegate = self;
UILabel *imageLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 40, 120, 700)];
imageLabel.backgroundColor = [UIColor greenColor];
[_bottomView addSubview:imageLabel];
[_scrollControl addSubview:_bottomView];
// Add to main view
[self.view addSubview:_scrollControl];
デリゲート メソッドを使用して目的の効果を達成しようとしましたが、下部の scrollView に切り替わる前に「マスター」scrollView のスクロールを停止できないようです。