可以在UIScrollview中使用childViewControllers吗?
我知道在ios5中我们可以使用childViewControllers控制屏幕中的多个视图.
我知道在ios5中我们可以使用childViewControllers控制屏幕中的多个视图.
我可以使用childViewControllers来控制uiscrollview中的每个视图吗?
我想要一个像Windows Phone 7全景图的效果,每个子控制器控制一个页面.
我不知道该怎么做.
还有一个问题:我正在尝试使用此代码,并遇到了问题.
[self addChildViewController: myTableViewController]; [scrollView addSubview:[[self.childViewControllers objectAtIndex:1] view]];
表视图可以显示,但是当我触摸行时,它无法推送到详细视图,表视图委托方法被选中不起作用.
有人可以帮帮我吗?非常感谢.
解决方法
这些代码使它成为现实:
- (void)configureInfoViewController { TodayViewController *todayVC = [self.storyboard instantiateViewControllerWithIdentifier:@"today"]; WeekViewController *weekVC = [self.storyboard instantiateViewControllerWithIdentifier:@"week"]; MonthViewController *monthVC = [self.storyboard instantiateViewControllerWithIdentifier:@"month"]; [self addChildViewController:todayVC]; [self addChildViewController:weekVC]; [self addChildViewController:monthVC]; } - (void)configureScrollView { [self.scrollView setDirectionalLockEnabled:YES]; self.scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * [self.childViewControllers count],scrollView.frame.size.height); for (int i = 0; i < [self.childViewControllers count]; i++) { CGRect frame = scrollView.frame; frame.origin.x = frame.size.width * i; frame.origin.y = 0; [[[self.childViewControllers objectAtIndex:i] view] setFrame:frame]; [scrollView addSubview:[[self.childViewControllers objectAtIndex:i] view]]; } }