Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 是否在UIScrollview中使用ChildViewController?_Ios_Uitableview_Ios5_Uiviewcontroller_Uiscrollview - Fatal编程技术网

Ios 是否在UIScrollview中使用ChildViewController?

Ios 是否在UIScrollview中使用ChildViewController?,ios,uitableview,ios5,uiviewcontroller,uiscrollview,Ios,Uitableview,Ios5,Uiviewcontroller,Uiscrollview,是否可以在UIScrollview中使用ChildViewController? 我知道在ios5中,我们可以使用ChildViewController来控制屏幕中的多个视图 我可以使用ChildViewController控制uiscrollview中的每个视图吗? 我想要一个类似WindowsPhone7Panorama的效果,每个子控制器控制一个页面。 我不知道该怎么做 还有一个问题:我正在尝试这个代码,但遇到了一个问题 [self addChildViewController: myTa

是否可以在UIScrollview中使用ChildViewController? 我知道在ios5中,我们可以使用ChildViewController来控制屏幕中的多个视图

我可以使用ChildViewController控制uiscrollview中的每个视图吗? 我想要一个类似WindowsPhone7Panorama的效果,每个子控制器控制一个页面。 我不知道该怎么做

还有一个问题:我正在尝试这个代码,但遇到了一个问题

[self addChildViewController: myTableViewController];
[scrollView addSubview:[[self.childViewControllers objectAtIndex:1] view]];
表格视图可以显示,但当我触摸该行时,它无法推送到详细视图,表格视图委托方法无法工作


有人能帮我吗?非常感谢。

在这里,您正在使用将子视图控制器添加到myTableViewController并尝试从自身访问子视图控制器


尝试从myTableViewController而不是从self获取childViewController。

以下是导致此情况发生的代码:

- (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]];
    }
}
-(无效)配置InfoViewController
{
TodayViewController*todayVC=[self.storyboard实例化eviewcontrollerwhiteIdentifier:@“今日”];
WeekViewController*weekVC=[self.storyboard instanceeviewcontrollerwhiteIdentifier:@“week”];
MonthViewController*monthVC=[self.storyboard实例化eviewcontrollerwhiteIdentifier:@“month”];
[self-addChildViewController:todayVC];
[self-addChildViewController:weekVC];
[self-addChildViewController:monthVC];
}
-(无效)配置滚动视图
{
[self.scrollView setDirectionalLockEnabled:是];
self.scrollView.contentSize=CGSizeMake(scrollView.frame.size.width*[self.childViewControllers count],scrollView.frame.size.height);
对于(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添加子视图:[[self.childViewController对象索引:i]视图];
}
}

是否设置了myTableViewController的委托属性?