AlertView.h file
#import <Foundation/Foundation.h>
@interface AlertView : NSObject
+ (void)showAlert:(NSString*)message;
+ (void)showAlert:(NSString*)message WithDelegate:(id)delegate;
+ (void)showAlert:(NSString*)message WithDelegate:(id)delegate andTag:(int)tag;
+ (void)showAlert:(NSString*)message WithDelegate:(id)delegate andTag:(int)tag andButtons:(NSString *)buttons;
+ (void)showDiscardAlert:(NSString*)message WithDelegate:(id)delegate andTag:(int)tag andButtons:(NSString *)buttons;
@end
================================
AlertView.m file
#import "AlertView.h"
#define title @"PrognoCIS"
@implementation AlertView
+(void) showAlert: (NSString*)message
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
+(void) showAlert: (NSString*)message WithDelegate:(id)delegate
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message
delegate:delegate cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
+ (void)showAlert:(NSString*)message WithDelegate:(id)delegate andTag:(int)tag
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:delegate
cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert setTag:tag];
[alert show];
}
+ (void)showAlert:(NSString*)message WithDelegate:(id)delegate andTag:(int)tag andButtons:(NSString *)buttons
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:message
delegate:delegate cancelButtonTitle:@"Cancel" otherButtonTitles: buttons, nil];
[alertView setTag:tag];
[alertView show];
}
+ (void)showDiscardAlert:(NSString*)message WithDelegate:(id)delegate andTag:(int)tag andButtons:(NSString *)buttons
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
message:message delegate:delegate cancelButtonTitle:@"Discard" otherButtonTitles: buttons, nil];
[alertView setTag:tag];
[alertView show];
}
@end
================================
Usage in any file :
[AlertView showAlert:@"Discard the changes?" WithDelegate:self andTag:3000 andButtons:@"Discard"];
No comments:
Post a Comment