I am creating UIView on top of tableview in which there will an imageview and on top of that there will be few buttons. This UiView will be shown when Change button(Navigation bar) is tapped. I have added everything programmtically. But i am not able to tap botton that are present in UIView
-(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;
}
}
The property of
userInteractionEnabledinUIImageViewis set toNOby default .. just make theimageView.userInteractionEnabled = YES;and it will work.