0

(self.bannerScrollView)我在宽度几乎是 iPad 宽度的水平滚动视图中有三个纵向图像。我正在尝试使用 aNSTimer来自动滚动图像。NSTimer委托方法被触发,但没有发生滚动。我已经浏览了这个网站上的所有链接,所以请不要发布任何指针。

[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(scrollingAuto)        userInfo:nil repeats:YES];
// [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

NSTimer委托方法:

-(void) scrollingAuto
{
    [self performSelectorOnMainThread:@selector(rotateBanner) withObject:nil waitUntilDone:YES];
}

-(void) rotateBanner
{
    CGRect frame = _bannerScrollView.frame;
    frame.origin.x =frame.size.width * self.bannerPageControl.currentPage;
    frame.origin.y = 0;
    [_bannerScrollView scrollRectToVisible:frame animated:YES];
    _pageControlIsChangingPage = YES;
}

我曾尝试将计时器放入 NSRunLoop 主循环中,正如您在上面所看到的那样。虽然与这个问题无关,但我也有一个与 scrolllview 关联的 UIpagecontrol:

- (IBAction) pageControlValueChanged: (UIPageControl *) sender
{
    CGRect frame = self.bannerScrollView.frame;
    frame.origin.x = frame.size.width * self.bannerPageControl.currentPage;
    frame.origin.y = 0;
    [self.bannerScrollView scrollRectToVisible:frame animated:YES];
    _pageControlIsChangingPage = YES;
}

控制台正在打印:

2013-05-29 10:28:57. [72189:c07] [ENTER -[NSITiPadIntroViewController scrollingAuto]]
2013-05-29 10:28:57. [72189:c07] [ENTER -[NSITiPadIntroViewController rotateBanner]]
2013-05-29 10:28:57. [72189:c07] [EXIT -[NSITiPadIntroViewController rotateBanner]]
2013-05-29 10:28:57. [72189:c07] [EXIT -[NSITiPadIntroViewController scrollingAuto]]
2013-05-29 10:28:57. [72189:c07] [ENTER -[NSITiPadIntroViewController scrollingAuto]]
2013-05-29 10:28:57. [72189:c07] [ENTER -[NSITiPadIntroViewController rotateBanner]]
2013-05-29 10:28:57. [72189:c07] [EXIT -[NSITiPadIntroViewController rotateBanner]]
2013-05-29 10:28:57. [72189:c07] [EXIT -[NSITiPadIntroViewController scrollingAuto]]
2013-05-29 10:28:57. [72189:c07] [ENTER -[NSITiPadIntroViewController scrollingAuto]]
2013-05-29 10:28:57. [72189:c07] [ENTER -[NSITiPadIntroViewController rotateBanner]]
2013-05-29 10:28:57. [72189:c07] [EXIT -[NSITiPadIntroViewController rotateBanner]]
2013-05-29 10:28:57. [72189:c07] [EXIT -[NSITiPadIntroViewController scrollingAuto]]
2013-05-29 10:28:57. [72189:c07] [ENTER -[NSITiPadIntroViewController scrollingAuto]]
2013-05-29 10:28:57. [72189:c07] [ENTER -[NSITiPadIntroViewController rotateBanner]]
2013-05-29 10:28:57. [72189:c07] [EXIT -[NSITiPadIntroViewController rotateBanner]]
2013-05-29 10:28:57. [72189:c07] [EXIT -[NSITiPadIntroViewController scrollingAuto]]

这意味着该方法正在被触发,但我看不到滚动发生。

4

0 回答 0