我有一个被调用UIViewController
的代表。我已将滚动视图的委托设置为视图控制器,但每当滚动视图滚动时,我都没有收到任何调用。这是实现:UIScrollView
NumberLineScroll
scrollViewDidScroll:
头UIViewController
文件(Game
):
@interface Game : UIViewController <LocDelegate, UIScrollViewDelegate, ResultsDelegate> {
...
NumberLineScroll* nline;
...
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
- (UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView;
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale;
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;
以及实现方法的主文件的组件:
- (void)viewDidLoad {
...
nline = [[NumberLineScroll alloc] initWithFrame: CGRectMake(0, -50, 1024, 400)];
[nline setScrollEnabled:YES];
[nline setContentSize:CGSizeMake(4100, 400)];
[self.view addSubview:nline];
nline.delegate = self;
nline.locDelegate = self; //this is for a Ball imageview that is implemented in NumberLineScroll
...
}
这是UIScrollView
(NumberLineScroll
)的实现:
头文件:
@interface NumberLineScroll : UIScrollView {
NumberLine* nline;
Ball* ball;
id <UIScrollViewDelegate> delegate;
id <LocDelegate> locDelegate;
}
@property(nonatomic, assign)id <UIScrollViewDelegate> delegate;
@property(nonatomic, assign)id <LocDelegate> locDelegate;
主文件中没有什么是非常相关的。我在那里做的唯一影响滚动的编程是关闭反弹并在用户移动球时关闭滚动,然后在他们完成时再次打开。此外,这locDelegate
不是问题,因为它工作得很好。主要问题是NumberLineScroll
没有进行委托调用。为什么是这样?
此外,其中的NumberLine
视图NumberLineScroll
是滚动视图的内容视图,仅用于说明。