I have this problem driving me crazy. I have spent decades to figure it out why this is happening.
I have a UIScrollView
as scrollView in a UIView
. In this scrollView, i have three different UIView
s which are created at runtime. In one of these three UIView
s, i create a button .Here is my code to do that.
UIButton *buttonLike = [UIButton buttonWithType:UIButtonTypeRoundedRect ] ;
buttonLike.frame =CGRectMake(scrollViewWidth +200, 30,36, 16);
buttonLike.imageView.image = [UIImage imageNamed:@"like.png"];
[buttonLike addTarget:self action:@selector(buttonLikePressed:) forControlEvents:UIControlEventTouchUpInside] ;
scrollViewWidth is a constant defined and initialized as well.
And,i add this buttonLike as a subview in one of the UIViews
. But,no matter what i do , buttonLikePressed method doesn't invoke.
I've searched this issue and came up with these solutions.
Iphone UIButton not working in nested UIViews
iPhone SDK 2: UIButton not working in nested views loaded from nib file
They described the same issue. But,as a solution they initialize their views using
-(id)initWithFrame:(CGRect)aRect
method. Well,i've already initialized my UIViews using initWithFrame
method. Do u guys have any idea how i can resolve this problem ?
Thank you all