UIViewControllerにUIDatePickerがあります。
ユーザーが日付を選択して UIDatePicker の外側をクリックした後、次のように UIDatePickerを非表示にします。
-(void)hidePicker
{
[UIView beginAnimations:@"SlideOutPicker" context:nil];
[UIView setAnimationDuration:0.5];
[_datePicker setCenter: CGPointApplyAffineTransform(_datePicker.center, _datePicker.transform)];
[_datePicker setTransform:CGAffineTransformMakeTranslation(0, 0)];
[UIView commitAnimations];
}
私は試します
[_datePicker addTarget:self action:@selector(hidePicker) forControlEvents:UIControlEventTouchUpOutside];
でもイベントが起こらないので、アドバイスをもらえますか?
ユーザーが日付を変更するたびにDatePickerを非表示にするべきではないため、UIControlEventValueChangedを使用したくありません