0
我正在創建一個顯示子視圖像ActionSheetView的應用程序,並且我已經通過插口添加了UIGridView和UIPageControll,但現在,當我單擊它沒有響應的單元格時,我的子視圖是一個ViewController筆尖文件。我的子視圖沒有響應點擊事件
如果我創建一個按鈕並以編程方式添加到我的popupview中,那麼它將顯示,並且還會獲得點擊事件,但任何插座都不會響應。
我試圖在我的子視圖中設置userinteraction使能,但它沒有任何好處。
這裏是我的第一個觀點的代碼,通過點擊barbutton顯示子視圖:
- (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";
}
這是怎麼在我的屏幕看起來像
UPDATE
現在我想通了我的問題是,問題是我給我的整個視圖一個龍頭列表,現在我添加網格視圖作爲子視圖,所以當我點擊單元格,而不是選擇單元格它w生病生成視圖雙擊手勢,爲什麼從來沒有選定單元格,多數民衆贊成,這就是我想..
但我的GridView沒有子視圖是添加在我的第二個視圖控制器,像MMGridView.still這項工作? –
任何你添加gridview的地方只要寫這個代碼夥計..就像[yourView bringSubviewToFront:yourGridView]; –
它使我的grideview在前面,但仍然touche不顯示。 –