2012-06-19 6 views
0

저는 imageview가 있고 그 위에 몇 개의 버튼이있는 tableview 위에 UIView를 만듭니다. 이 UiView는 변경 버튼 (탐색 표시 줄)을 두드리면 표시됩니다. 프로그래밍 방식으로 모든 것을 추가했습니다. 하지만 난 그냥 imageView.userInteractionEnabled = YES;을하고 그것을 작동합니다 .. UIView의UIButton을 클릭 할 수 없습니다. iphone

-(IBAction)changeViewController:(id)sender { 
    if(!isViewShowing){ 
     NSLog(@"show Imageview"); 
     viewContainer = [[UIView alloc] initWithFrame: CGRectMake (276, 2, 40, 230)]; 
     UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 230)]; 
     [imageView setImage:[UIImage imageNamed:@"bar.png"]]; 
     UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
     [button addTarget:self action:@selector(buttonPressedAction:)forControlEvents:UIControlEventTouchUpInside]; 
     //[button setTitle:@"Show View" forState:UIControlStateNormal]; 
     button.frame = CGRectMake(0.0, 25.0, 36.0, 36.0); 
     [button setBackgroundImage:[UIImage imageNamed:@"OLFB icon.png"] forState:UIControlStateNormal]; 

     [imageView addSubview:button]; 
     //[imageView release]; 
     [viewContainer addSubview: imageView]; 

     [self.view addSubview:viewContainer]; 
     [self.view bringSubviewToFront:button]; 
     //[polygonView release]; 
     isViewShowing=YES; 
    } 
    else 
    { 
     NSLog(@"view not showing"); 
     [viewContainer removeFromSuperview]; 
     isViewShowing=NO; 
    } 

} 

답변

3

UIImageViewuserInteractionEnabled의 속성이 기본적으로 NO로 설정에 있는지 botton을을 탭 할 수 없습니다입니다.

+0

감사합니다. 덕분에 – user1288005

0

오 마이 갓. imageView의 userInteractionEnabled를 YES로 설정하면 imageView에 추가 된 버튼이 click 이벤트에 응답하게됩니다.

imageView.userInteractionEnabled = YES; 
+0

감사합니다. 근무했습니다. – user1288005

관련 문제