我在宽度几乎为iPad宽度的水平滚动视图(self.bannerScrollView)
中有三张肖像图像。我正在尝试使用NSTimer
自动滚动图像。 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]]
这意味着该方法被触发但我看不到滚动发生。