开发者

touch began in UIScrollView

开发者 https://www.devze.com 2023-01-19 21:35 出处:网络
touchesBegan: d开发者_StackOverflow中文版oesn\'t work in UIScrollView. How do I enable touchesBegan: in UIScrollView?You have to subclass UIScrollView to allow interception of the touch events.

touchesBegan: d开发者_StackOverflow中文版oesn't work in UIScrollView. How do I enable touchesBegan: in UIScrollView?


You have to subclass UIScrollView to allow interception of the touch events.

For example, you could create a "special" UISCrollView like this:

@interface TouchableScrollView : UIScrollView {

}
@end

.m file:

@implementation TouchableScrollView

- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {

    if (!self.dragging) {
        [self.nextResponder touchesEnded: touches withEvent:event]; 
    }       

    [super touchesEnded: touches withEvent: event];
}

@end

This example only overrides touchesEnded, but you can do the same for touchesBegan


I assume that u are seeking for code to scroll down and hide the scroll down Img. so this is the code.

// scroll down image show and hidder.
    - (void)scrollViewDidScroll:(UIScrollView *)myScrollView{
        //NSLog(@"%lf",myScrollView.contentOffset.y);
        if (myScrollView.contentOffset.y > 220 )
            scrollDownImg.hidden = YES ;
        else 
            scrollDownImg.hidden = NO ;

    }

U may get the scrolled location by using the myScrollView.contentOffset

0

精彩评论

暂无评论...
验证码 换一张
取 消