Search code examples
iphonexcodedelegatesuiscrollviewuiscrollviewdelegate

why UIScrollView doesnt call it's Delegate?


the problem is I make a new UIScrollView at Xib and then link the delegate to owner.. some how the delegate doesnt called.. any clue? or simple example for UIScrollView

sorry I am a new ios developer and thank in advance..

the code :

at header

@interface stageViewController : UIViewController<UIScrollViewDelegate>

at .m

#pragma mark drag delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSLog(@"scrollViewDidScroll");
}                                              // any offset changes
- (void)scrollViewDidZoom:(UIScrollView *)scrollView{
    NSLog(@"scrollViewDidZoom");
}

// called on start of dragging (may require some time and or distance to move)
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    NSLog(@"scrollViewWillBeginDragging");
}

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
    NSLog(@"scrollViewWillEndDragging");
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    NSLog(@"scrollViewWillBeginDecelerating");
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSLog(@"scrollViewDidEndDecelerating");
}

Solution

  • Write scrollView.delegate = self; If you have made it pragmatically. And if you have your ScrollView in XIB then ctrl+drag from your scrollView to your File's Owner and then set its delegate.