所以,我有一个来自UICollecionView项目的segue被点击到UIPageViewController。当PageViewController显示时,导航栏显示为深灰色,其中的UIView具有奇怪的偏移量。 但是,在屏幕上的任何地方点击一次后,我看到一个奇怪的“动画”,UIView移动到正确的位置。 因此,屏幕上的所有视图都会被移动。
以下是包含此错误的5秒视频的链接:http://www.youtube.com/watch?v=CNbwBGvSzIk
PageViewController.m:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = [[[EVAEvent events] objectAtIndex:self.currentIndex] name];
self.dataSource = self;
self.delegate = self;
UIViewController *vc = [self viewControllerAtIndex:self.currentIndex];
NSArray *controllers = [NSArray arrayWithObjects:vc, nil];
[self setViewControllers:controllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
}
- (UIViewController *)viewControllerAtIndex:(NSUInteger)index;
{
// NSLog(@"View Controller At Index = %lu", (unsigned long)self.currentIndex);
EVAEventInfoViewController *controller = [EVAEventInfoViewController getFromStoryboard];
EVAEvent *event = [[EVAEvent events] objectAtIndex:index];
[controller setIndex:index];
[controller setEvent:event];
return controller;
}
EVAEventInfoViewController.m:
+ (EVAEventInfoViewController *) getFromStoryboard
{
//NSLog(@"Creating EVAEventInfoViewController");
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
EVAEventInfoViewController *this = (EVAEventInfoViewController *)[sb instantiateViewControllerWithIdentifier:@"eventInfoController"];
return this;
}
非常感谢!
答案 0 :(得分:25)
尝试添加
self.automaticallyAdjustsScrollViewInsets=NO;
答案 1 :(得分:1)
我设置了UIPageViewController和子视图控制器
self.automaticallyAdjustsScrollViewInsets=NO;
但如果 UITabBarController 以root用户身份无效。
您可以看到UIPageViewControllerContentView是正确的位置(0,0)。但 在_UIQueuingScrollView下的UIView生成了状态栏的偏移量。
所以,我决定不使用UIPageViewController。我使用self.view addSubView来解决这个问题。
- (void)loadVC:(UIViewController*)vc
{
[self addChildViewController:vc];
vc.view.frame = self.view.bounds;
[self.view addSubview:vc.view];
}