ios中的滑动

scrollView上连续滑动的问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@interface ViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) TestScrollView *scr1;
@property (nonatomic, strong) UIScrollView *scr2;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.scr1];
}
- (UIScrollView *)scr1 {
if (!_scr1) {
_scr1 = [[UIScrollView alloc] init];
CGFloat width = [UIScreen mainScreen].bounds.size.width;
CGFloat height = [UIScreen mainScreen].bounds.size.height;
_scr1.frame = CGRectMake(0, 0, width, height);
_scr1.backgroundColor = [UIColor orangeColor];
_scr1.contentSize = CGSizeMake(width * 2, height);
_scr1.pagingEnabled = YES;
_scr1.delegate = self;
[_scr1 addSubview:self.scr2];
}
return _scr1;
}
- (UIScrollView *)scr2 {
if (!_scr2) {
_scr2 = [[UIScrollView alloc] init];
CGFloat width = [UIScreen mainScreen].bounds.size.width;
CGFloat height = [UIScreen mainScreen].bounds.size.height;
_scr2.frame = CGRectMake(0, 50, width, height - 50);
_scr2.backgroundColor = [UIColor blueColor];
_scr2.contentSize = CGSizeMake(width * 2, 0);
_scr2.pagingEnabled = YES;
_scr2.delegate = self;
}
return _scr2;
}
@end

scrollView上叠加scrollVie的时候,当滑动上边的Scr的时候

  • 如果上边的可以滑动,那么就是上边的scrollView来响应事件
  • 如果已经滑动到边界,那么就是下边的scrollView来响应事件