我刚刚切换到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上,这三个视图可以彼此重叠显示,而在iOS7上,它们可以正确显示(横坐标为0,一个为x = 320,另一个为x = 640)。有谁知道如何解决这个问题?
非常感谢
我找到了答案。我使用了中间变量,并且有效。不要为什么。如果有人有答案,我会很高兴听到。
无论如何,有效的代码在这里:
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];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句