gpt4 book ai didi

ios - ScrollView 类 iOS

转载 作者:行者123 更新时间:2023-12-01 18:30:21 25 4
gpt4 key购买 nike

我的程序甚至没有进入 scrollViewDidScroll方法。我不知道为什么。我的 View 确实加载看起来像这样:

- (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");
}

最佳答案

试用:

self.scrollView.delegate = self;

希望这可以帮助。

关于ios - ScrollView 类 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9687029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com