gpt4 book ai didi

objective-c - 刷新 UIViewController 的界面方向

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

我有一个带有分页 ScrollView 的 View Controller ,向用户显示数据页面。当用户在滚动到下一页/上一页的过程中旋转设备时,我无法让 ScrollView “对齐”页面。

我注意到在 native 照片查看器应用程序中,滚动期间基本上禁用了旋转。我试图模仿这种行为。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (isScrolling)
return interfaceOrientation == self.interfaceOrientation;
return YES;
}

问题是我需要一些方法来告诉运行时我已经准备好改变我的方向了。类似于 setNeedsLayout 的东西,但适用于 View Controller 。
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
isScrolling = NO;
//something to get the interface orientation updated
}

这是一个小问题,但它让我发疯。有任何想法吗?

最佳答案

纯粹的猜测,但也许可以尝试这样的事情?

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}

关于objective-c - 刷新 UIViewController 的界面方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7432551/

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