UILabel doesn't show inputView

前端 未结 7 1299
长发绾君心
长发绾君心 2020-12-18 07:14

I would use a UILabel to allow users to select a date with UIDatePicker.

To do this, I created an UILabel subclass overwriting the inputView and the inputAccessoryVi

7条回答
  •  没有蜡笔的小新
    2020-12-18 07:36

    You can just ovveride inputView getter method, like explained in Apple documentation:

    - (UIView *)inputView {
        return myInputView;
    }
    - (BOOL)canBecomeFirstResponder {
        return YES;
    }
    

    Then add a gesture or a button to call becomeFirstResponder:

    - (void)showInputView:(id)sender {
         [self becomeFirstResponder];
    }
    

提交回复
热议问题