Ios5 容器视图控制器的子视图控制器中的句柄UIButton

Ios5 容器视图控制器的子视图控制器中的句柄UIButton,ios5,uibutton,parent-child,viewcontroller,containment,Ios5,Uibutton,Parent Child,Viewcontroller,Containment,我正在创建自定义容器ViewController类,能够创建5个子ViewController,并能够使用以下API从一个子视图控制器移动到另一个子视图控制器: transitionFromViewController:fromViewController toViewController:toViewController duration:1.0 options:0 animations:^{

我正在创建自定义容器ViewController类,能够创建5个子ViewController,并能够使用以下API从一个子视图控制器移动到另一个子视图控制器:

transitionFromViewController:fromViewController
        toViewController:toViewController
            duration:1.0
             options:0
          animations:^{
                              }
          completion:^(BOOL finished) {
                          }];
子视图控制器占用了父视图控制器的一部分。每次当用户刷卡时,我正在使前一个控制器熄灭,而当前控制器在可显示区域出现

现在我在子视图控制器上有了按钮,当我点击它们时,我并没有得到子视图控制器的动作方法的事件或触发器。但即使当前显示了childview,父视图控制器也会收到其按钮的回调。在下面添加代码片段(虽然它稍微大一点,但这将帮助您分析我是否犯了任何错误)

父视图控制器:

- (void) handleSwipeGestureLeft:(UISwipeGestureRecognizer *)gesture
{
    if (showPopupValue) {
        return;
    }

    NSInteger index = [arrayOfChildVCs indexOfObject:selectedViewController];
    index = MIN(index+1, [arrayOfChildVCs count]-1);

    UIViewController *newSubViewController = [arrayOfChildVCs objectAtIndex:index];


    endFrame.origin.x = -1024;

    startOfNewVCFrame.origin.x = 1024;

    [self transitionFromViewController:selectedViewController toViewController:newSubViewController];
    selectedViewController = newSubViewController;

}
- (void) handleSwipeGestureRight:(UISwipeGestureRecognizer *)gesture
{
    if (showPopupValue) {
        return;
    }

    NSInteger index = [arrayOfChildVCs indexOfObject:selectedViewController];
    index = MAX(index-1, 0);

    UIViewController *newSubViewController = [arrayOfChildVCs objectAtIndex:index];

    endFrame.origin.x = 1024;

    startOfNewVCFrame.origin.x = -1024;

    [self transitionFromViewController:selectedViewController toViewController:newSubViewController]; 
    selectedViewController = newSubViewController;

}

- (void) populateChildVCList
{


    if (self.currentactivity == EPI_Normal) 
    {
        arrayOfImageNames = [[NSArray alloc]initWithObjects:@"AD_Initiate_SPI_Normal.jpg", @"AD_Initiate_CPI_Normal.jpg", @"AD_Initiate_EAC_Normal.jpg", @"AD_Initiate_PV_Normal.jpg", @"AD_Initiate_EV_Normal.jpg", nil];
    }
    else 
    {
        arrayOfImageNames = [[NSArray alloc]initWithObjects:@"AD_Initiate_SPI_Trigger.jpg", @"AD_Initiate_CPI_Trigger.jpg", @"AD_Initiate_EAC_Trigger.jpg", @"AD_Initiate_PV_Trigger.jpg", @"AD_Initiate_EV_Trigger.jpg", nil];
        isTriggerOn = YES;
    }


    arrayOfChildVCs = [[NSMutableArray alloc] init];

    [arrayOfChildVCs addObject:[[PopupDummyViewController alloc]initWithNibName:@"PopupDummyViewController" bundle:nil]]; // Note: Add one dummy VC to initiate swap

    for (int vcIndex = 0; vcIndex < [arrayOfImageNames count]; vcIndex++) 
    {
        PiSLAComplianceViewController *childPopupController = [[PiSLAComplianceViewController alloc]initWithNibName:@"PiSLAComplianceViewController" bundle:nil];

        childPopupController.popUpImageName = [arrayOfImageNames objectAtIndex:vcIndex];
        childPopupController.imageIndex = vcIndex;
        childPopupController.isTriggerOn = isTriggerOn;

        [arrayOfChildVCs addObject:childPopupController];
    }

    selectedViewController = [arrayOfChildVCs objectAtIndex:0];
    selectedViewController.view.frame = CGRectMake(0, 100, 100, 511); // Took the imageview coordinates
    // Add the dummy view controller to Container View Initially
    [self addChildViewController:selectedViewController];

    [self.view addSubview:selectedViewController.view];

    // notify it that move is done
    [selectedViewController didMoveToParentViewController:self];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    [super viewDidLoad];

    UISwipeGestureRecognizer *swipeGestureRecognizerRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGestureRight:)];
    [swipeGestureRecognizerRight setDirection:UISwipeGestureRecognizerDirectionRight];
    [ self.view addGestureRecognizer:swipeGestureRecognizerRight];

    UISwipeGestureRecognizer *swipeGestureRecognizerLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGestureLeft:)];
    [swipeGestureRecognizerLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
    [ self.view addGestureRecognizer:swipeGestureRecognizerLeft];

    endFrame = deliverableimageview.frame;
    startOfNewVCFrame = deliverableimageview.frame;

    [self populateChildVCList]; // To Create list of child view controllers and loads one invisible dummy view controller to be ready for swiping

}

- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController
{
    if (fromViewController == toViewController)
    {
        // cannot transition to same
        return;
    }

    // animation setup


    toViewController.view.frame = startOfNewVCFrame;

    // notify
    [fromViewController willMoveToParentViewController:nil];
    [self addChildViewController:toViewController];

    // transition
    [self transitionFromViewController:fromViewController
                      toViewController:toViewController
                              duration:1.0
                               options:0
                            animations:^{
                                toViewController.view.frame = fromViewController.view.frame;
                                fromViewController.view.frame = endFrame;
                            }
                            completion:^(BOOL finished) {
                                [toViewController didMoveToParentViewController:self];
                                [fromViewController removeFromParentViewController];

                            }];



}
-(void)无手柄WipeGestureLeft:(UISwipeGestureRecognitor*)手势
{
if(showPopupValue){
返回;
}
NSInteger索引=[arrayOfChildVCs indexOfObject:selectedViewController];
索引=MIN(索引+1,[arrayOfChildVCs计数]-1);
UIViewController*newSubViewController=[arrayOfChildVCs对象索引:索引];
endFrame.origin.x=-1024;
startOfNewVCFrame.origin.x=1024;
[从ViewController:selectedViewController到ViewController:newSubViewController的自转换];
selectedViewController=newSubViewController;
}
-(无效)无手柄WipeGestureRight:(UISwipeGestureRecognitor*)手势
{
if(showPopupValue){
返回;
}
NSInteger索引=[arrayOfChildVCs indexOfObject:selectedViewController];
指数=最大值(指数-1,0);
UIViewController*newSubViewController=[arrayOfChildVCs对象索引:索引];
endFrame.origin.x=1024;
startOfNewVCFrame.origin.x=-1024;
[从ViewController:selectedViewController到ViewController:newSubViewController的自转换];
selectedViewController=newSubViewController;
}
-(无效)populateChildVCList
{
if(self.currentactivity==EPI_Normal)
{
arrayOfImageNames=[[NSArray alloc]initWithObjects:@“AD_Initiate_SPI_Normal.jpg”,“AD_Initiate_CPI_Normal.jpg”,“AD_Initiate_EAC_Normal.jpg”,“AD_Initiate_PV_Normal.jpg”,“AD_Initiate_EV_Normal.jpg”,nil];
}
其他的
{
arrayOfImageNames=[[NSArray alloc]initWithObjects:@“AD_Initiate_SPI_Trigger.jpg”,“AD_Initiate_CPI_Trigger.jpg”,“AD_Initiate_EAC_Trigger.jpg”,“AD_Initiate_PV_Trigger.jpg”,“AD_Initiate_EV_Trigger.jpg”,nil];
isTriggerOn=是;
}
arrayOfChildVCs=[[NSMutableArray alloc]init];
[arrayOfChildVCs addObject:[PopupDummyViewController alloc]initWithNibName:@“PopupDummyViewController”捆绑包:nil];//注意:添加一个虚拟VC以启动交换
对于(int vcIndex=0;vcIndex<[arrayOfImageNames计数];vcIndex++)
{
PiSLAComplianceViewController*childPopupController=[[PiSLAComplianceViewController alloc]initWithNibName:@“PiSLAComplianceViewController”捆绑包:nil];
childPopupController.popUpImageName=[arrayOfImageNames对象索引:vcIndex];
childPopupController.imageIndex=vcIndex;
childPopupController.isTriggerOn=isTriggerOn;
[arrayOfChildVCs addObject:childPopupController];
}
selectedViewController=[arrayOfChildVCs对象索引:0];
selectedViewController.view.frame=CGRectMake(0,100100511);//获取imageview坐标
//最初将虚拟视图控制器添加到容器视图
[self-addChildViewController:selectedViewController];
[self.view addSubview:selectedViewController.view];
//通知它移动已完成
[选择的ViewController didMoveToParentViewController:self];
}
-(无效)viewDidLoad
{
[超级视图下载];
//从nib加载视图后,执行任何其他设置。
[超级视图下载];
UISwipegestureRecognitzer*SwipegestureRecognitzerRight=[[UISwipegestureRecognitzer alloc]initWithTarget:self action:@selector(handleSwipeGestureRight:)];
[SwipegestureRecognitzerRight设置方向:UISwipegestureRecognitzerDirectionRight];
[self.view addgesturecognizer:swipgesturerecognizerright];
UISwipegestureRecognitzer*SwipegestureRecognitzerLeft=[[UISwipegestureRecognitzer alloc]initWithTarget:self action:@selector(handleSwipeGestureLeft:)];
[SwipegestureRecognitzerLeft设置方向:UISwipegestureRecognitzerDirectionLeft];
[self.view addgesturecognizer:swipgesterecognizerLeft];
endFrame=可交付成果ImageView.frame;
startOfNewVCFrame=可交付成果ImageView.frame;
[self populateChildVCList];//创建子视图控制器的列表,并加载一个不可见的虚拟视图控制器以准备进行滑动
}
-(void)从ViewController:(UIViewController*)从ViewController到ViewController:(UIViewController*)到ViewController的转换
{
if(fromViewController==toViewController)
{
//无法转换到相同的
返回;
}
//动画设置
toViewController.view.frame=startOfNewVCFrame;
//通知
[从ViewController将移动到ArentViewController:nil];
[self-addChildViewController:toViewController];
//过渡
[自转换fromViewController:fromViewController
toViewController:toViewController
持续时间:1.0
选项:0
动画:^{
toViewController.view.frame=来自ViewController.view.frame;
fromViewController.view.frame=结束帧;
}
完成:^(布尔完成){
[toViewController-didMoveToParentViewController:self];
[fromViewController removeFromParentViewController];
}];
}

父视图控制器不在子vi的响应器链中吗