i´ve built a nested scroll view. in the view.xib there is in the view one scrollview with vertical scrolling named rootScroll. in this one there are two other scrollviews with horizontal scrolling named topScroll and bottomScroll.
my goal is to fade out bottomScroll when user drags the topScroll and fade it in again when decelerating ends.
the code workes fine so far. the only problem is that scrollViewWillBeginDragging gets messages from all three UIScrollViews. i´ve logged the sender and can see that they´re different but anyway i don´t know how to restrict the animation only to messages sent by the topScroll!
how can i distinguish different senders inside of scrollViewWillBeginDragging?
probably an objective-c absolute beginners question. i hope someone will give me a hint anyway.
thank you!
- (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];
}
Set the
tagpropeties of the scrollviews in Interface Builder. You can then use[sender tag]in your method to tell them apart.