About
Home > Tutorials Home > Ios > UIAlertView Example in iOS

UIAlertView Example in iOS

Published on October 17, 2019 7:59:56 PM

alert-view

This Application helps you to create a demo application for UIAlertview.



Step 1 : Open the XCode and create a new Single View Based Application template. Give the application name "UIAlertviewDemo". Copy this Code to the ViewController.h and hook up the properties with appropriate control.

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *txtName;
- (IBAction)displayAlert:(id)sender;
@end

Step 2 : Copy the Following Code into your ViewController.m File.

#import "ViewController.h"
@implementation ViewController
@synthesize txtName;
- (IBAction)displayAlert:(id)sender
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"System Message" message:[NSString stringWithFormat:@"Welcome, %@",[txtName text]] delegate:nil cancelButtonTitle:@"Okey" otherButtonTitles:nil, nil];
    [alert show];
}
@end

UIAlertView Example in iOS - Video Tutorial