4

It is possible that use childViewControllers in UIScrollview? I have known that in ios5 we can use childViewControllers to control several views in screen.

Can i use childViewControllers to control each view in uiscrollview? I want an effect like windows phone 7 panorama, and each child controller control a page. And I don't know how to do that.

One more question: I'm trying this code, and got an issue.

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

The table view can display, but when i touch the row, it can't push to detail view, the table view delegate methods didselected didn't work.

someone can help me? Thanks so much.

lancy
  • 857
  • 6
  • 22

2 Answers2

1

These are the code that make it happened:

- (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]];
    }
}
lancy
  • 857
  • 6
  • 22
0

Here you are using adding child view controller to myTableViewController and trying to access childViewController from the self..?

Try getting childViewController from myTableViewController not from self.