NSExceptional / TBAlertController

UIAlertController, UIAlertView, and UIActionSheet unified for developers wanting to support iOS 7 and 8.
MIT License
37 stars 6 forks source link

Can't set keyboardType or initial text #3

Closed rfloydb closed 8 years ago

rfloydb commented 9 years ago

I've made some modifications for my project to allow setting of keyboardType and text of the textFields. I would offer a pull request, but I implemented it by adding a property called textFieldInfo consisting of an NSArray of NSDictionaries. I think it might be more elegant to make textFieldInputStrings readwrite and maybe add textFieldKeyboardTypes array, or just allow the passing in of an array of textFields, with some convenience methods to set them up, since it makes the API a bit verbose.

As I said, happy to share my code. Thanks for the head start on this.

NSExceptional commented 9 years ago

TBAlertController actually just passes those configuration handlers over to the UIAlertController API. Does setting the text not seem to stick or something?

How are you accomplishing this?

Also, textFieldInputStrings is only filled after the alert has been dismissed. You've brought to my attention that this API needs to be revised, as that's a pretty weird thing to do now that I think about it. I should have a block callback property instead which takes the array of strings.

rfloydb commented 9 years ago

You can control additional text fields no problem, but if you're just using the standard UIAlertViewStylePlainTextInput, for example, you have no control over that input. My app also sets autocapitalizationType on the fields, so my clunky array of dictionaries is already starting to look clunkier.

NSExceptional commented 9 years ago

Well, that's how the standard value works… You should use that when you want a simple, default text field. If you want additional customization, use addTextFieldWithConfigurationHandler:

NSExceptional commented 9 years ago

I've just pushed a new version of the pod, which removes textFieldInputStrings, since each button action block is already passed the same array, there's no reason to have it as a property on the alert itself.