ios - 快速点击 IO 页面控件切换页面时,当前指示器移动到页面前面
问题描述
在我的 Xamarin.IOs 项目中,我有一个 UIPageControl,它与启用分页的 UICollectionView 相结合。
我使用该CardPageControl.PrimaryActionTriggered
事件来处理滑动页面。
CardPageControl.PrimaryActionTriggered += OnPageControlTapped;
private async void OnPageControlTapped(object sender, EventArgs e)
{
// SetContentOffset of the collection view
}
但是当我快速点击 PageControl 时,当前指示器会移动到当前页面的前面,然后在点击结束后,当前指示器会重新定位在正确的指示器中。
我怎样才能解决这个问题?
解决方案
您必须启用DefersCurrentPageDisplay。默认情况下这是错误的。
CardPageControl.DefersCurrentPageDisplay = true;
然后在OnPageControlTapped内部,调用CardPageControl的UpdateCurrentPageDisplay(),
private async void OnPageControlTapped(object sender, EventArgs e)
{
// SetContentOffset of the collection view
CardPageControl.UpdateCurrentPageDisplay();
}
这将使 PageControl 当前指示器与当前页面同步。
推荐阅读
- javascript - 如何通过jquery仅清除文本而不清除其他元素?
- math - SageMath 绘制函数的 x 轴除法
- .net-core - 带有 API 调用的 WebSocket
- python - 如何使用python在另一个文件中获取两个excel文件的差异
- php - docker入口点sh文件重新启动
- python-3.x - 我定义了一个函数,但是在调用该函数时我没有得到任何值
- wordpress - 向 woocommerce 结帐页面添加自定义字段会禁用下订单按钮功能
- reactjs - 选择 React 功能组件中的所有复选框失败,我怀疑是由于渲染发生得太快
- amazon-web-services - Python3 和 aws-cli 版本不同
- javascript - 获取本地 IP 配置,包括 DHCP 值 nodejs