我使用以下代码初始化新的UIScrollView:
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.showsHorizontalScrollIndicator = NO;
scroll.showsVerticalScrollIndicator = NO;然后,我在scrollView实例中添加了3个UIView实例。
但是当我使用它的委托方法- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView和- (void)scrollViewDidScroll:(UIScrollView *)scrollView时
这两个方法都不起作用,我输入了一个NSLog方法来捕获GDB中的日志。
到底怎么回事?
发布于 2012-03-16 17:31:46
将您自己添加为UIScrollView的委派
scroll.delegate = self;发布于 2014-10-20 17:24:16
您可以在viewdidload中添加此代码
ScrollView.delegate = self;或来自storyboard/xib的链接
并记住在接口后添加UIScrollViewDelegate
@interface ViewController ()<UIScrollViewDelegate>
@endhttps://stackoverflow.com/questions/9734724
复制相似问题