У меня есть вид, и в этом представлении я добавил UITapGesture
. Теперь, когда я помещаю кнопку в представление и нажимаю кнопку, она не вызывает действие кнопки.Действие UIButton не вызывается, когда UITapGesture в представлении
Вот мой код:
ButtionView=[[UIView alloc]initWithFrame:CGRectMake(x, y, 84, 84)];
ButtionView.tag=i;
UIImageView *coverImageView = [[UIImageView alloc]
initWithFrame:CGRectMake(0,0,ButtionView.frame.size.width,84)];
coverImageView.tag = i;
UIButton *notesbutton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
notesbutton.frame=CGRectMake(0, 0,20,20);
notesbutton.tag=i;
[notesbutton addTarget:self action:@selector(buttonClickedForNotes:)
forControlEvents:UIControlEventTouchUpInside];
[ButtionView addSubview:coverImageView];
[ButtionView addSubview:notesbutton];
[notesbutton bringSubviewToFront:ButtionView];
[self.scrollview addSubview:ButtionView];
[ButtionView addGestureRecognizer:oneFingerSingleTap];
-(IBAction)buttonClickedForNotes:(id) sender
{
NSLog(@"buttion action call");
}
Посмотрите на этот вопрос, он должен быть вам проблема http://stackoverflow.com/questions/4825199/gesture-recognizer-and-button-actions –