0
사용자가 정보를 표시하기 위해 확장 및 축소 할 수있는 서랍 UIContainerView를 구현하려고합니다. 내가 컨테이너보기를 설정하고 "확장"버튼이 잘 작동합니다.UIContainerView 이벤트 후 터치에 응답하지 않습니다. iOS
그러나보기가 '확장'되면 더 이상 터치에 응답하지 않습니다. 텍스트보기와 두 개의 단추가 있습니다. 더 나아가; 화면을 터치하면 콜렉션 뷰에 탭으로 등록되며, 상호 작용할 수있는 버튼이 아닙니다.
// Parent View Controller.h
{
UIViewController *child1;
profileDescriptionViewController *profileDescription;
}
// Parent View Controller.m
- (void)viewDidLoad
{
child1 = [self.storyboard instantiateViewControllerWithIdentifier:@"profileDescription"];
[child1 didMoveToParentViewController:self];
}
// Child View Controller.m
- (void)viewDidLoad
{
_profileDescription.text = [[dataHandler getAthlete] profileDescriptionString];
_isExposed = NO;
_frame = self.view.frame;
_height = _frame.size.height;
_yOrigin = _frame.origin.y;
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (IBAction)profileExpand:(id)sender
{
if (_isExposed == NO) {
[UIView animateWithDuration:0.5 animations:^
{
//0, 487, 320, 32
[self.view setFrame:CGRectMake(_frame.origin.x, _yOrigin - 100, 320, _yOrigin + 150)];
}
completion:^(BOOL finished)
{
[self.view setUserInteractionEnabled:YES];
_isExposed = YES;
}];
}
/* else
{
[UIView animateWithDuration:0.5 animations:^
{
[self.view setFrame:CGRectMake(_frame.origin.x, _yOrigin + 100, 320, _yOrigin - 150)];
}
completion:^(BOOL finished)
{
_isExposed = NO;
}];
}*/
}
난 그냥보기 터치 이벤트에 응답 할 :
이
은 컨테이너 볼 수있는 부모/자식 관계를 처리하는 코드입니다.parentViewController
에있는 UI 요소 뒤에 배치되지는 않지만 상단 또는 설명에서 단추를 선택할 수 없으며 대신 그 요소 뒤에있는 요소와 상호 작용합니다.
누구에게 이것이 왜 그런지에 대한 아이디어가 있습니까? 스토리 보드에서 일반 컨테이너보기처럼 설정합니다.
이보기에서 "상호 작용 사용"이 설정되어 있습니까? – Tuan
하위보기 컨트롤러의 viewDidLoad 메서드에'userInteraction : YES'가 있습니다 –
아마도 프레임 계산이 잘못되었을 수 있습니다. 그것을 확인하기 위해 클립의 경계에 클립을 설정하십시오. 프레임이 너무 작아서보기가 보이지만 터치 할 수없는 경우가 있습니다. – Tuan