여러 개의 팝업보기가보기 컨트롤러의 속성으로 저장되어 있습니다. 표시 될 때보기에만 추가되고 숨겨진 경우보기에서 제거됩니다. 모든 일을하고 있었지만 일을 단순화하기 위해 코드를 변경했으며 더 이상 작동하지 않습니다. 일반적으로 다른 코드는 사용자 지정 설정하면 문에서이UIGestureRecognizers가 응답하지 않습니다.
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hidePopUpView:)];
[self.totalPowerPopUpView addGestureRecognizer:tapGestureRecognizer];
[self.co2PopUpView addGestureRecognizer:tapGestureRecognizer];
견해가있는 UIButton을 (눌러 트리거 선택기에 의해 제공됩니다 : 여기
은 내 제스처 인식기를 생성하고 추가하는 방법의 예입니다 속성보기,하지만 난) 단순화를 위해 그것을 잘라 :- (void)showPopUpView:(UIButton*)sender
{
CGRect endFrame = CGRectMake(10, 10, 300, 400);
UIView *popUpView;
if (sender == self.totalPowerInfoButton)
{
[self.view addSubview:self.totalPowerPopUpView];
popUpView = self.totalPowerPopUpView;
}
if (sender == self.co2LevelInfoButton)
{
[self.view addSubview:self.co2PopUpView];
popUpView = self.co2PopUpView;
}
[UIView animateWithDuration:0.5
animations:^ {
popUpView.alpha = 1.0;
popUpView.frame = endFrame;
}];
}
popUpView의 현재,하지만 난 그들을 누를 때 제스처 인식기 선택 호출되지 않습니다. 왜 안돼?
예. 제스처 인식기를 여러보기에 연결할 수 없다고 생각합니까? – Darren
예. 제스처 인식기는보기 목록이 아닌 속성으로 첨부 된보기를 가지므로 하나만 첨부 할 수 있습니다. – yuf
아, 설명 주셔서 감사합니다! – Darren