Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 3 compatibility #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 50 additions & 35 deletions TSAlertView/TSAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,69 @@
//
// 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;
UITextField *_inputTextField;
NSMutableArray *_buttons;
NSInteger _cancelButtonIndex;
TSAlertViewButtonLayout _buttonLayout;
NSInteger _firstOtherButtonIndex;
CGFloat _width;
CGFloat _maxHeight;
BOOL _usesMessageTextView;
TSAlertViewStyle _style;
}
@property(nonatomic, copy) NSString *title;
@property(nonatomic, copy) NSString *message;
Expand All @@ -64,18 +79,18 @@ typedef enum
@property(nonatomic, assign) CGFloat width;
@property(nonatomic, assign) CGFloat maxHeight;
@property(nonatomic, assign) BOOL usesMessageTextView;
@property(nonatomic, retain) UIImage* backgroundImage;
@property(nonatomic, retain) UIImage *backgroundImage;
@property(nonatomic, assign) TSAlertViewStyle style;
@property(nonatomic, readonly) UITextField* inputTextField;
@property(nonatomic, readonly) UITextField *inputTextField;

- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...;
- (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




Loading