iPhone – UIAlertView example in iphone

This is an simple UIAlertView example.UIAlertView is used for the notification purpose.

Step 1: Start the program by opening the Xcode. select the option Create a new Xcode Project.

Step 2: Select the option Single view Application.

Step 3: Drag a button from object library and place it on the viewController.xib file.

Step 4: Now place the mouse over the button and right click on it and drag a line on the ViewController.h as shown below.

Step 5: Now a small window appears,here select ‘Action’ option on the Connection field.Give a name for your button method and click connect.

Step 6: Now inside the method add the code below to the ViewController.m file.

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@”I am a AlertView” message:nil delegate:self cancelButtonTitle:@”Ok” otherButtonTitles:nil, nil];   // Creating a UIAlertView object

[alert show];          //Calling the AlertView
[alert release];      //Now the alert object is released from the stack memory

Step 8: Now Run the Project.

OUTPUT:

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s