问题
I could add a textfield in UIAlertController using
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
}];
Is there any possibility to add a custom textfield inside an alert controller?
回答1:
I do not think that it's possible to use a UITextField
subclass in an UIAlertController
. You can only edit the textfield's properties in the configuration handler.
回答2:
No, you can't. You have to implement custom Alert View for this purpose. You can try libraries - ALERT ACTION SHEET LIBRARIES.
Or if you need text field with UIAlertView
its self with a 'clean' look - UITextField in UIAlertController (border, backgroundColor)
来源:https://stackoverflow.com/questions/45758565/custom-textfield-in-uialertcontroller