gpt4 book ai didi

iphone - 如何将scrollViewWillBeginDragging限制为仅一个发送者对象?

转载 作者:行者123 更新时间:2023-11-29 05:06:12 25 4
gpt4 key购买 nike

我已经构建了一个嵌套 ScrollView 。在 view.xib 中, View 中有一个名为 rootScroll 的垂直滚动 ScrollView 。在这个 View 中,还有另外两个具有水平滚动功能的 ScrollView ,名为 topScroll 和 BottomScroll。

我的目标是当用户拖动topScroll时淡出bottomScroll,并在减速结束时再次淡入。

到目前为止,代码运行良好。唯一的问题是,scrollViewWillBeginDragging 从所有三个 UIScrollView 获取消息。我已经记录了发送者并且可以看到它们是不同的,但无论如何我不知道如何将动画限制为仅由 topScroll 发送的消息!

如何区分scrollViewWillBeginDragging内的不同发件人?

可能是 Objective-C 绝对初学者的问题。无论如何,我希望有人能给我提示。

谢谢!

- (void)viewDidLoad {
[super viewDidLoad];

// rootScroll
[rootScroll setScrollEnabled:YES];
[rootScroll setContentSize:CGSizeMake(1024, 1980)];

// topScroll
[topScroll setScrollEnabled:YES];
[topScroll setContentSize:CGSizeMake(3072, 406)];

// bottomScroll
[bottomScroll setScrollEnabled:YES];
[bottomScroll setContentSize:CGSizeMake(3072, 188)];
}


- (void)scrollViewWillBeginDragging:(UIScrollView *)sender
{
NSLog(@"will begin dragging, %i", sender);

[UIScrollView beginAnimations:nil context:nil];
[UIScrollView setAnimationDuration:0.15f];
[self.bottomScroll setAlpha:0.0];
[UIScrollView commitAnimations];

}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)sender
{
NSLog(@"end position");

[UIScrollView beginAnimations:nil context:nil];
[UIScrollView setAnimationDuration:1.5f];
[self.bottomScroll setAlpha:1.0];
[UIScrollView commitAnimations];

}

最佳答案

在 Interface Builder 中设置 ScrollView 的 tag 属性。然后,您可以在方法中使用[sender tag]来区分它们。

关于iphone - 如何将scrollViewWillBeginDragging限制为仅一个发送者对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5069804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com