我刚刚切换到iOS7 SDK。 我的应用程序在此之前在iOS6上运行良好,但现在没有了,除了它现在在iOS7上正常工作。
我有一个带页面控件的scrollView,可以显示3个不同的选项卡,其中包含以下设置:
self.scrollView.pagingEnabled = YES;
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * 3, self.scrollView.frame.size.height);
self.scrollView.showsHorizontalScrollIndicator = NO;
self.scrollView.showsVerticalScrollIndicator = NO;
self.scrollView.scrollsToTop = NO;
self.scrollView.delegate = self;
我添加了这个scrollView我的3个视图,我从3个不同的故事板加载:
UIStoryboard *timelineStoryboard=[UIStoryboard storyboardWithName:@"timelineStoryboard" bundle:nil];
TabBarViewController *mainVC=[timelineStoryboard instantiateInitialViewController];
self.currentViewController =mainVC;
[mainVC.view setFrame:CGRectMake(320, 20, mainVC.view.frame.size.width, mainVC.view.frame.size.height)];
[self.scrollView addSubview:mainVC.view];
[self addChildViewController:mainVC];
UIStoryboard *expenseStoryboard=[UIStoryboard storyboardWithName:@"expenseStoryboard" bundle:nil];
TabBarViewController *leftVC=[expenseStoryboard instantiateInitialViewController];
self.leftViewController =leftVC;
[leftVC.view setFrame:CGRectMake(0, 20, leftVC.view.frame.size.width, leftVC.view.frame.size.height)];
[self.leftViewController.view setFrame:CGRectMake(0, 20, leftVC.view.frame.size.width, leftVC.view.frame.size.height)];
[self.scrollView addSubview:leftVC.view];
[self addChildViewController:leftVC];
UIStoryboard *dashboardStoryboard=[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
TabBarViewController *rightVC=[dashboardStoryboard instantiateViewControllerWithIdentifier:@"dashboardVC"];
self.leftViewController =rightVC;
[rightVC.view setFrame:CGRectMake(640, 20, rightVC.view.frame.size.width, rightVC.view.frame.size.height)];
[self.scrollView addSubview:rightVC.view];
[self addChildViewController:rightVC];
在iOS6上,这3个视图显示在彼此之上,而在iOS7上它们被正确显示(在横坐标为0时,一个在x = 320处,另一个在x = 640处)。 有没有人知道如何解决这个问题?
非常感谢
答案 0 :(得分:0)
我找到了答案。我使用了中间变量,它起作用了。不过不知道为什么。 如果有人有答案,我很高兴听到它。
无论如何,有效的代码在这里:
UIStoryboard *dashboardStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
TabBarViewController *rightVC = [dashboardStoryboard instantiateViewControllerWithIdentifier:@"dashboardVC"];
UIView *dashboardView = rightVC.view;
[dashboardView setFrame:CGRectMake(640,
20,
320,
screenHeight+20)];
[self.scrollView addSubview:dashboardView];
[self addChildViewController:rightVC];