ChildViewController中的半滑动不会收到事件

时间:2013-10-08 22:19:22

标签: ios objective-c uiviewcontroller storyboard

我在故事板中有一个名为A的UITableViewController,现在我尝试在我的mainviewcontroller上滑动A.

_vc = [self.storyboard instantiateViewControllerWithIdentifier:@“A”];

在我的showMenu方法

[self addChildViewController:self.vc];
[self.view addSubview:self.vc.view];
[self.vc didMoveToParentViewController:self];

[UIView animateWithDuration:0.7 animations:^{
    [self.view setFrame:CGRectMake(160, 0, self.view.frame.size.width, self.view.frame.size.height)];
}];

我可以在viewcontroller A中滑动。但无论我尝试用A做什么,我都没有得到回应。如何让A响应触摸事件?

1 个答案:

答案 0 :(得分:0)

试试这个,

self.viewControllerA = [self.storyboard instantiateViewControllerWithIdentifier:@"A"];
    [self.viewControllerA.view setFrame:CGRectMake(160, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self addChildViewController:self.viewControllerA];
    [self.view addSubview:self.viewControllerA.view];

    [UIView animateWithDuration:0.50f animations:^{
        [self.viewControllerA.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    } completion:^(BOOL finished) {
        [self.viewControllerA didMoveToParentViewController:self];
    }];