【发布时间】:2012-03-30 00:44:16
【问题描述】:
我的程序甚至没有进入scrollViewDidScroll 方法。我不知道为什么。我的视图确实加载看起来像这样:
- (void)viewDidLoad
{
[super viewDidLoad];
// Set the size of the content to be displayed
self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width * ScrollViewControllerNumberOfPages, self.scrollView.bounds.size.height);
// Turn on paging in the scroll view (can also be done in Interface Builder)
self.scrollView.pagingEnabled = YES;
NSLog(@"CurrentPage ViewDidLoad%@",self.pageControl.currentPage);
switch (self.pageControl.currentPage)
{
case 1:
[self.minkyImageView setImage:[UIImage imageNamed:@"monkey_1.png"]];
NSLog(@"case1");
break;
case 2:
[self.minkyImageView setImage:[UIImage imageNamed:@"Shape1.png"]];
NSLog(@"case2");
break;
default:
break;
}
}
我还像这样在我的界面上实现了scrollviewDelegate。我不明白我做错了什么。它甚至没有进入名为scrollViewDidScroll 的方法。
@interface MinkyScreenSwapViewController: UIViewController <UIScrollViewDelegate>
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat contentWidth = scrollView.bounds.size.width;
CGFloat halfContentWidth = contentWidth / 2;
NSInteger currentPage = (scrollView.contentOffset.x + halfContentWidth) / contentWidth;
self.pageControl.currentPage = currentPage;
NSLog(@"CurrentPage");
}
【问题讨论】:
标签: ios iphone objective-c ios4 uiscrollview