Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.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
Iphone 我的子视图没有响应单击事件_Iphone_Ios_Gridview_Touch - Fatal编程技术网

Iphone 我的子视图没有响应单击事件

Iphone 我的子视图没有响应单击事件,iphone,ios,gridview,touch,Iphone,Ios,Gridview,Touch,我正在创建一个像ActionSheetView一样显示子视图的应用程序,我通过outlet添加了UIGridView和UIPageControll,但现在当我单击单元格时,它没有响应,我的子视图是一个带有nib文件的ViewController 如果我创建一个按钮并以编程方式添加到我的popupview中,那么它将显示,并且也会得到click事件,但是outlet中的任何内容都不会响应 我尝试在我的子视图中设置userinteraction enable,但没有任何效果 以下是我的代码,用于通过

我正在创建一个像ActionSheetView一样显示子视图的应用程序,我通过outlet添加了UIGridView和UIPageControll,但现在当我单击单元格时,它没有响应,我的子视图是一个带有nib文件的ViewController

如果我创建一个按钮并以编程方式添加到我的popupview中,那么它将显示,并且也会得到click事件,但是outlet中的任何内容都不会响应

我尝试在我的子视图中设置userinteraction enable,但没有任何效果

以下是我的代码,用于通过单击按钮显示子视图的第一个视图:

- (void)popUpView:(id)sender {
    //self.view.backgroundColor = [UIColor darkGrayColor];

   bGView = [[UIView alloc] init];   /this is the background view and all view is added in it
    bGView.frame = CGRectMake(0,0,320,490);
    bGView.backgroundColor = [UIColor clearColor];
    bGView.alpha = 0.8 ;

    CGRect  viewFrame = CGRectMake(10, 90, 300, 300);
    aPopUpViewController = [[PopUpViewController alloc] initWithNibName:@"PopUpViewController" bundle:nil];        //this is my view controller and when this shows on screen it display my greed view

    aPopUpViewController.view.frame = viewFrame; 
    aPopUpViewController.view.userInteractionEnabled = YES;

    [bGView addSubview:aPopUpViewController.view];

    button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button addTarget:self 
               action:@selector(aMethod:)
     forControlEvents:UIControlEventTouchDown];
    button.backgroundColor = [UIColor clearColor];
    [button setBackgroundImage:[UIImage imageNamed:@"close_button.png"] forState:UIControlStateNormal];
    button.frame = CGRectMake(-1, 80, 30, 30);
    [bGView addSubview:button];

    //for view animation

    /*
    // from bottom to center animation

    [bGView setFrame:CGRectMake( 0.0f, 480.0f, 320.0f, 480.0f)]; //notice this is OFF screen!
    [UIView beginAnimations:@"animateTableView" context:nil];
    [UIView setAnimationDuration:0.4];
    [bGView setFrame:CGRectMake( 0.0f, 0.0f, 320.0f, 480.0f)]; //notice this is ON screen!
    [UIView commitAnimations];*/

    //for page like effect

    /*[UIView transitionWithView:self.view duration:0.5
                       options:UIViewAnimationOptionTransitionCurlUp //change to whatever animation you like
                    animations:^ { [self.view addSubview:bGView]; }
                    completion:nil];*/

    /*CATransition *transition = [CATransition animation];
     transition.duration = 1.0;
     transition.type = kCATransitionReveal; //choose your animation
     [bGView.layer addAnimation:transition forKey:nil];
     [self.view addSubview:bGView];*/

    aPopUpViewController.view.userInteractionEnabled = YES;
    bGView.userInteractionEnabled = YES;
    self.view.userInteractionEnabled = YES;

    bGView.transform = CGAffineTransformMakeScale(0.01, 0.01);
    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        bGView.transform = CGAffineTransformIdentity;
    } completion:^(BOOL finished){
        // do something once the animation finishes, put it here
    }];

     [self.view addSubview:bGView];


    addLabel.enabled = NO;
    clipArt.enabled = NO;
    emailItem.enabled = NO;
    closeButton.enabled = NO;
    self.navigationController.topViewController.title = @"Choose ClipArt";

    ExampleAppDataObject* theDataObject = [self theAppDataObject];

   theDataObject.navBarHide = @"no";

}

- (void)aMethod:(id)sender
{
    //[aPopUpViewController.view removeFromSuperview];
    //[button removeFromSuperview];

    /*[UIView transitionWithView:self.view duration:0.5
                       options:UIViewAnimationOptionTransitionCrossDissolve//change to whatever animation you like
                    animations:^ { [bGView removeFromSuperview]; }
                    completion:nil];*/

    [bGView removeFromSuperview];

    addLabel.enabled = YES;
    clipArt.enabled = YES;
    emailItem.enabled = YES;
    closeButton.enabled = YES;

    self.navigationController.topViewController.title = @"Greeting's";

    ExampleAppDataObject* theDataObject = [self theAppDataObject];

    theDataObject.navBarHide = @"yes";
}
这就是我的屏幕的样子

更新


现在我发现了我的问题,问题是我给了我的整个视图一个点击列表,现在我添加了网格视图作为子视图,所以当我点击单元格而不是选择单元格时,它将生成视图点击手势,这就是为什么单元格从未选中,这就是我的想法。

在主视图中添加每个子视图后添加这一行

[self.view bringSubviewToFront:yourGridView];

但是我的gridview不是子视图,它是添加到我的第二个视图控制器中的,比如MMGridView。仍然可以吗?任何添加gridview的地方都只需编写以下代码dude。。比如[yourView将子视图带到前面:yourGridView];它使我的GridView在前面,但仍然无法显示touche。您可以从出口处将其交给学员吗?您可以卸下geasture,然后再试一次吗??