I have a UITextfield dedicated to dates. When clicked I have a method that shows a UIView with a UIDatePicker as a subview and a method to hide it again. By default this UIView is hidden.

I've noticed that the textfields of my form are no longer clickable. However my UIButtons are still working.

The UIView is a subview of the superview that the UITextFields and UIButtons are also part of. The UIView also takes up the whole area of the window.

The UIView is an outlet also.

Does anyone have any idea what is happening here?

Kind regard

Code:

- (void) hidePickerView {
    [UIView animateWithDuration:0.5
                     animations:^{
                         [[self datePickerView] setFrame:CGRectMake(0, -250, 320, 50)];
                     } completion:^(BOOL finished) {
                         [[self datePickerView] removeFromSuperview];
                     }];
}

I've also tried putting the following in my viewDidLoad method:

[[self datePickerView] removeFromSuperview];
有帮助吗?

解决方案

I was returning NO in my - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField method. Setting this to yes solved the problem.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top