Skip to content

Loading…

Multiple UITextFields #9

Open
wants to merge 12 commits into from
Commits on Aug 8, 2011
  1. @hellhound

    Coding style

    hellhound committed
  2. @hellhound
Commits on Aug 10, 2011
  1. @hellhound
Commits on Aug 13, 2011
  1. @hellhound
Commits on Aug 16, 2011
  1. @hellhound
  2. @hellhound
  3. @hellhound

    Bugfix: memory leakage while creating the first UITextField. Feature:…

    hellhound committed
    … new API for multiple UITextField administration
Commits on Aug 18, 2011
  1. @hellhound

    Adding userInfo

    hellhound committed
Commits on Sep 2, 2011
  1. @hellhound
Commits on Sep 4, 2011
  1. @hellhound
  2. @hellhound
Commits on Nov 30, 2011
  1. @hellhound

    Adding ignore rules

    hellhound committed
This page is out of date. Refresh to see the latest.
Showing with 1,021 additions and 734 deletions.
  1. +42 −0 .gitignore
  2. +97 −47 TSAlertView/TSAlertView.h
  3. +882 −687 TSAlertView/TSAlertView.m
View
42 .gitignore
@@ -0,0 +1,42 @@
+# Bit Zeppelin .gitignore (iPhone projects)
+# based on http://blog.illuminex.com/2009/10/better-sample-gitignore-file-for-xcode.html
+# Mac OS X Finder and whatnot
+.DS_Store
+
+# Sparkle distribution Private Key (Don't check me in!)
+dsa_priv.pem
+
+# XCode (and ancestors) per-user config (very noisy, and not relevant)
+*.mode1
+*.mode1v3
+*.mode2v3
+*.perspective
+*.perspectivev3
+*.pbxuser
+*.xcworkspace/
+xcuserdata/
+.LSOverride
+
+# Generated files
+VersionX-revision.h
+
+# build products
+build/
+*.[oa]
+
+# Other source repository archive directories (protects when importing)
+.hg
+.svn
+CVS
+
+# automatic backup files
+*~.nib
+*.swp
+*~
+*(Autosaved).rtfd/
+Backup[ ]of[ ]*.pages/
+Backup[ ]of[ ]*.key/
+Backup[ ]of[ ]*.numbers/
+
+# others
+*.pyc
View
144 TSAlertView/TSAlertView.h
@@ -3,79 +3,129 @@
//
// Created by Nick Hodapp aka Tom Swift on 1/19/11.
//
-
-
+#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef enum
{
- TSAlertViewButtonLayoutNormal,
- TSAlertViewButtonLayoutStacked
-
+ TSAlertViewButtonLayoutNormal,
+ TSAlertViewButtonLayoutStacked
+
} TSAlertViewButtonLayout;
typedef enum
{
- TSAlertViewStyleNormal,
- TSAlertViewStyleInput,
-
+ TSAlertViewStyleNormal,
+ TSAlertViewStyleInput,
+
} TSAlertViewStyle;
@class TSAlertViewController;
@class TSAlertView;
@protocol TSAlertViewDelegate <NSObject>
-@optional
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(TSAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
+@optional
+// Called when a button is clicked. The view will be automatically dismissed
+// after this call returns
+- (void) alertView:(TSAlertView *)alertView
+ clickedButtonAtIndex:(NSInteger)buttonIndex;
-// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
+// Called when we cancel a view (eg. the user clicks the Home button). This is
+// not called when the user clicks the cancel button.
// If not defined in the delegate, we simulate a click in the cancel button
- (void)alertViewCancel:(TSAlertView *)alertView;
-- (void)willPresentAlertView:(TSAlertView *)alertView; // before animation and showing view
-- (void)didPresentAlertView:(TSAlertView *)alertView; // after animation
-
-- (void)alertView:(TSAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex; // before animation and hiding view
-- (void)alertView:(TSAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex; // after animation
-
+// Before animation and showing view
+- (void)willPresentAlertView:(TSAlertView *)alertView;
+// After animation
+- (void)didPresentAlertView:(TSAlertView *)alertView;
+
+// Before animation and hiding view
+- (void) alertView:(TSAlertView *)alertView
+ willDismissWithButtonIndex:(NSInteger)buttonIndex;
+// After animation
+- (void) alertView:(TSAlertView *)alertView
+didDismissWithButtonIndex:(NSInteger)buttonIndex;
@end
-@interface TSAlertView : UIView
+@interface TSAlertView: UIView
{
- UIImage* _backgroundImage;
- UILabel* _titleLabel;
- UILabel* _messageLabel;
- UITextView* _messageTextView;
- UIImageView* _messageTextViewMaskImageView;
- UITextField* _inputTextField;
- NSMutableArray* _buttons;
+ id<TSAlertViewDelegate> _delegate;
+ UIImage *_backgroundImage;
+ UILabel *_titleLabel;
+ UILabel *_messageLabel;
+ UITextView *_messageTextView;
+ UIImageView *_messageTextViewMaskImageView;
+ NSMutableArray *_buttons;
+ NSInteger _cancelButtonIndex;
+ TSAlertViewButtonLayout _buttonLayout;
+ NSInteger _firstOtherButtonIndex;
+ CGFloat _width;
+ CGFloat _maxHeight;
+ NSUInteger _shouldNotAdmitBlanks;
+ BOOL _usesMessageTextView;
+ TSAlertViewStyle _style;
+ // TSAlertView (TSCustomizableAlertView)
+ NSMutableArray *_textFields;
+ id _userInfo;
}
-@property(nonatomic, copy) NSString *title;
-@property(nonatomic, copy) NSString *message;
-@property(nonatomic, assign) id<TSAlertViewDelegate> delegate;
-@property(nonatomic) NSInteger cancelButtonIndex;
-@property(nonatomic, readonly) NSInteger firstOtherButtonIndex;
-@property(nonatomic, readonly) NSInteger numberOfButtons;
-@property(nonatomic, readonly, getter=isVisible) BOOL visible;
-@property(nonatomic, assign) TSAlertViewButtonLayout buttonLayout;
-@property(nonatomic, assign) CGFloat width;
-@property(nonatomic, assign) CGFloat maxHeight;
-@property(nonatomic, assign) BOOL usesMessageTextView;
-@property(nonatomic, retain) UIImage* backgroundImage;
-@property(nonatomic, assign) TSAlertViewStyle style;
-@property(nonatomic, readonly) UITextField* inputTextField;
-
-- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...;
+@property (nonatomic, copy) NSString *title;
+@property (nonatomic, copy) NSString *message;
+@property (nonatomic, assign) id<TSAlertViewDelegate> delegate;
+@property (nonatomic, assign) NSInteger cancelButtonIndex;
+@property (nonatomic, readonly) NSInteger firstOtherButtonIndex;
+@property (nonatomic, readonly) NSInteger numberOfButtons;
+@property (nonatomic, readonly, getter=isVisible) BOOL visible;
+// shouldNotAdmitBlanks are flags, for each UITextField, from lest significant
+// (i.e. [_textFields objectAtIndex:0]) to most significant bit
+// (i.e. [_textFIelds objectAtIndex:n - 1]).
+// By default shouldNotAdmitBlanks has its flags set for each initialzed
+// UITextField
+@property (nonatomic, assign) NSUInteger shouldNotAdmitBlanks;
+@property (nonatomic, assign) BOOL usesMessageTextView;
+
+@property (nonatomic, assign) TSAlertViewButtonLayout buttonLayout;
+@property (nonatomic, assign) CGFloat width;
+@property (nonatomic, assign) CGFloat maxHeight;
+@property (nonatomic, retain) UIImage *backgroundImage;
+@property (nonatomic, assign) TSAlertViewStyle style;
+@property (nonatomic, readonly) UITextField *inputTextField;
+@property (nonatomic, retain) id userInfo;
+
+- (id)initWithTitle:(NSString *)title
+ message:(NSString *)message
+ delegate:(id)delegate
+ cancelButtonTitle:(NSString *)cancelButtonTitle
+ otherButtonTitles:(NSString *)otherButtonTitles, ...;
- (NSInteger)addButtonWithTitle:(NSString *)title;
- (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;
-- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
+- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex
+ animated:(BOOL)animated;
- (void)show;
-
@end
-
-
-
+@interface TSAlertView (TSCustomizableAlertView)
+
+// Returns the number of text fields added to the current instance
+@property (nonatomic, readonly) NSInteger numberOfTextFields;
+// Returns the first text field, identical to the message textFieldForIndex:
+// with 0 as it argument, with the exception that firstTextField will return nil
+// if there aren't any text fields, whereas textFieldForIndex: will throw an
+// exception
+@property (nonatomic, readonly) UITextField *firstTextField;
+
+// Allows you to add a UITextField directly, without having TSAlertView to
+// create it for you
+- (void)addTextField:(UITextField *)textField;
+// Creates and adds a UITextField, setting the placeholder value to the label
+// parameter
+- (UITextField *)addTextFieldWithLabel:(NSString *)label;
+// Creates and adds a UITextField, setting the placeholder value to the label
+// parameter, and the text value to the value parameter
+- (UITextField *)addTextFieldWithLabel:(NSString *)label
+ value:(NSString *)value;
+// Returns the UITextField instance at the specified index. Note: this method
+- (UITextField *)textFieldAtIndex:(NSInteger)index;
+@end
View
1,569 TSAlertView/TSAlertView.m
882 additions, 687 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
Something went wrong with that request. Please try again.