gpt4 book ai didi

objective-c - 有什么方法可以操纵父 View Controller ,以便 subview 位于 UIPageControl 下方?

转载 作者:太空狗 更新时间:2023-10-30 03:44:32 24 4
gpt4 key购买 nike

我通过使用 UIPageViewController 在应用程序中实现水平滚动,我将导航属性设置为“水平”并将过渡样式设置为“滚动”。一切正常,我可以添加一些正确显示的 subview 。我还想通过使用这两种方法来利用 UIPageViewController 的内置 UIPageControl:

-(NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
-(NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController

这实际上显示了我正在寻找的内容:指示显示哪个 subview 的点。但是,正如您在图像中看到的,UIPageControl 设置在父 View Controller (UIPageViewController)的底部。您可以想象这不是我想要的呈现 UIPageControl 的方式。有什么方法可以操纵父 View Controller ,以便 subview 位于 UIPageControl 下方?或者还有其他好的做法可以实现这一目标吗?我知道我可以通过使用 scrollView 而不是 UIPageViewController 来实现水平滚动,但这对我来说似乎更有效。

http://i48.tinypic.com/2hd03ev.png

为清楚起见:灰色部分是我的 subview ,红色部分是我正在使用的底层 UIPageViewController。

提前感谢您的回答!

最佳答案

一种解决方案是创建和管理您自己的 UIPageControl而不是使用内置的。

如果您创建了自己的多个选项,可以按您想要的深度显示它,但我建议在 UIPageViewController 之上创建一个覆盖 View 。并将 UIPageControl 添加到其中,以便两者完全独立。您还可以将页面控件放置在任何您想要的位置。

要跟踪页面更改,请实现 UIPageViewControllerDelegateUIPageViewController并将 View Controller 更改转发给您的 UIPageControl使用 setCurrentPagesetNumberOfPages .

关于objective-c - 有什么方法可以操纵父 View Controller ,以便 subview 位于 UIPageControl 下方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14982927/

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