gpt4 book ai didi

ios - UIPageViewController 检测平移手势

转载 作者:可可西里 更新时间:2023-11-01 05:20:41 24 4
gpt4 key购买 nike

有没有办法在向左/向右滑动时确定 UIPageViewController 的平移位置?我一直在努力实现这一点,但它没有用。我添加了一个 UIPageViewController 作为 subview ,我可以水平向左/向右滑动它以在页面之间切换,但是我需要确定我在屏幕上平移的位置的 x、y 坐标。

最佳答案

我想出了如何做到这一点。基本上 UIPageViewController 使用 UIScrollViews 作为它的 subview 。我创建了一个循环并设置了所有的 UIScrollViews subview ,并将它们的委托(delegate)分配给了我的 ViewController。

/**
* Set the UIScrollViews that are part of the UIPageViewController to delegate to this class,
* that way we can know when the user is panning left/right
*/
-(void)initializeScrollViewDelegates
{
UIScrollView *pageScrollView;
for (UIView* view in self.pageViewController.view.subviews){
if([view isKindOfClass:[UIScrollView class]])
{
pageScrollView = (UIScrollView *)view;
pageScrollView.delegate = self;
}
}
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"Im scrolling, yay!");
}

关于ios - UIPageViewController 检测平移手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28949537/

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