UIAlertView subclass that adds support for UITextFields, without using any private methods.
Latest commit 4b02169 Nov 17, 2009 @shnhrrsn shnhrrsn first commit
Permalink
Failed to load latest commit information.
Demo
.gitignore
EGOTextFieldAlertView.h
EGOTextFieldAlertView.m
README.textile

README.textile

EGOTextFieldAlertView

Created by enormego

EGOTextFieldAlertView is a subclass of UIAlertView that adds support for UITextFields, without needing to use any of the private methods, to avoid your binary being rejected from AppStore.

Text fields will look identical to the ones in the private methods for UIAlertView, however the method calls are different, so there’s no chance of tripping Apple’s analyzer.

Methods

- (void)addTextField:(UITextField*)textField;
Allows you to add a UITextField directly, without having EGOTextFieldAlertView create it for you.

- (UITextField*)addTextFieldWithLabel:(NSString*)label;
Creates and adds a UITextField, setting the placeholder value to the label parameter.

- (UITextField*)addTextFieldWithLabel:(NSString*)label value:(NSString*)value;
Creates and adds a UITextField, setting the placeholder value to the label parameter, and the text value to the value parameter.

- (UITextField*)textFieldForIndex:(NSInteger)index;
Returns the UITextField instance at the specified index. Note: This method is not called “textFieldAtIndex:” because there’s a private method in UIAlertView with that name.

@property(nonatomic,readonly) NSInteger numberOfTextFields;
Returns the number of text fields added to the current instance

@property(nonatomic,readonly) UITextField* firstTextField;
Returns the first text field, identical to calling [alertView textFieldForIndex:0], with the exception that firstTextField will return nil if there aren’t any text fields, where as textFieldForIndex will throw an exception.

License

EGOTextFieldAlertView is available under the MIT license:

Copyright © 2009 enormego

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.