Use ChildViewControllers in UIScrollview?

Is it possible that using childViewControllers in a UIScrollview? I knew that in ios5 we can use childViewControllers to control multiple views on the screen.

Is it possible to use childViewControllers to control each view in uiscrollview? I need an effect, such as Windows Phone 7 panorama, and each child controller controls the page. And I do not know how to do this.

One more question: I am trying to use this code and the problem.

[self addChildViewController: myTableViewController]; [scrollView addSubview:[[self.childViewControllers objectAtIndex:1] view]]; 

The table view may be displayed, but when I touch the row, it cannot click on the detailed view, the delegation methods of the table view didselected do not work.

can someone help me? Many thanks.

+4
source share
2 answers

This is the code that does this:

 - (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]]; } } 
+1
source

Here you are using the child view controller add in myTableViewController and trying to access childViewController from itself.?

Try to get childViewController from myTableViewController out of control.

0
source

Source: https://habr.com/ru/post/1393823/


All Articles