모달 창과 같이 보이거나 숨기는 UISegmentedControl이 있습니다. 처음에는 선택한 세그먼트가 없습니다. IB에서 값 변경 이벤트는 - (IBAction) cardClassificationChanged : (UISegmentedControl *) 보낸 사람에게 연결됩니다. 내가 마지막 줄 (-hideWithAnimation에 대한 호출을) 주석 경우애니메이션 전에 UISegmentedControl 선택이 업데이트되지 않습니다.
- (IBAction)cardClassificationChanged:(UISegmentedControl *)sender
{
NSLog(@"%d", sender.selectedSegmentIndex);
// block for updating the categorization of current card asynchronously
[self.cardActionSheet hideWithAnimation];
}
이 예상대로 선택이 변경, 모든 작품 : 여기에 그 방법이다. 그러나 해당 애니메이션 메서드를 호출하면 UISegmentedControl 선택 항목이 애니메이션 전에 시각적으로 변경되지 않습니다.
- (void)hideWithAnimation
{
CATransition *animation = [CATransition animation];
animation.type = kCATransitionFade;
animation.duration = globalAnimationLength;
[self.layer addAnimation:animation forKey:nil];
self.hidden = YES;
}
이 뷰 (a에서 터치 동작) 다음에 나타나는 시간은 UISegmentedControl 비록 선택된 정확한 세그먼트를 가질 것이다 : 여기 hideWithAnimation 방법이다.
UISegmentedControl에 setNeedsDisplay를 호출 할 필요는 없지만 cardClassificationChanged 메서드 나 hideWithAnimation 메서드로 실험 할 때도 새로 고쳐지지 않습니다.
분명히 UI 업데이트와 관련된 뭔가가 누락되었습니다. 애니메이션보다 먼저 UISegmentedControl 선택 항목을 업데이트하려면 무엇을 호출해야합니까?
에서 호출되지 않습니다 -hideWithAnimation' 방법을'시도'-cardClassificationChanged :','-hideCardActionSheet이'대신이라고합니다. 복사 된 코드를 확인하고 수정 해 주시겠습니까? –
네 말이 맞아. 혼란스러워서 미안해. -hideCardActionSheet에는 다른 논리/처리가 있고 -hideWithAnimation이 호출됩니다. 나는 그 기계로 돌아갈 수있을 때 갱신 할 것이다. 현재로서는 cardClassificationChanged 내부의 애니메이션이나 로직에 문제가 없지만 UISegmentedControl이 선택을 반영하여 시각적으로 업데이트되지 않는다는 점이 문제점입니다. – aaronfalls
@ A-Live 편집 됨, 지적 해 주셔서 감사합니다. – aaronfalls