I have imageview
in which I am adding UIButton
it shows button when I click on button it does not call the action of the button. Here is the code I am using I have also set the imageView.userInteraction=enabled
but still it is not calling the action.
UIImageView*myImageView=[[UIImageView alloc] initWithFrame:CGRectMake(75,10,200,150)];
myImageView.image=thumbnail;
myImageView.userInteractionEnabled=YES;
[scrollView addSubview:myImageView];
UIButton*playButton=[[UIButton alloc] initWithFrame:CGRectMake(20,20,128,128)];
//[playButton setImage:[UIImage imageNamed:@"playIconPlay.png"] forState:UIControlStateNormal];
[playButton.buttonType:UIButtonTypeRoundedRect];
scrollView.userInteractionEnabled=YES;
myImageView.userInteractionEnabled=YES;
[playButton setTitle:@"Play Click" forState:UIControlStateNormal];
[playButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[playButton addTarget:self action:@selector(playButtonAction) forControlEvents:UIControlEventTouchUpInside];
myImageView.userInteractionEnabled=YES;
[myImageView addSubview:playButton];
Before adding your Button as subview, please set the
exclusiveTouch
property toYES
.Hope it Will help you.... enjoy coding..!!!
you can add a UIImageView and and UIButton in a UIView, hope it will help for you.
Try this.. It will work Perfectly..