Search TekSocial
Stay Connected

Enter your email address:

(We respect your privacy!)

Or subscribe with your favorite RSS Reader

  

« Looking for new speakers? | Main | A Basic Login PHP Script »
12:35PM

Button Press Pop Up Alert

Introduction:

Hey guys, in this tutorial I will be teaching you how to make a pop up alert in your application. What a pop up alert does is when a user taps a button an alert will pop up with some information and you can dismiss it once your done reading. Its a simple application however the code is quite long so be sure to use the picture follow ups as well as a video I am going to add on when we go into IB.

Step 1:

Open up Xcode, go to File, New Project, and select a View Based Application. Title the application whatever fits your needs however I am going to title it PopUpAlert.

Picture 1

Step 2:

Now that we have set up our Project go into our Nib Files and double click the ViewController.xib. Here I will add a video tutorial to show you what to do in IB with adding the button as well as the action. I feel that I should do this more often seeing as text isn’t the best way to teach IB especially when first starting out in iPhone Development.

 

Step 3:

As you can see in your products folder you have your MainView.m and your MainView.h. We are going to go ahead and drag those into our Classes folder and select the .h folder to start up the coding process for the pop up alert.

Picture 6

Step 4:

In your MainView.h highlight all the green text starting from /* and replace the green text with UIView. Make sure your open bracket sign is one space after UIView otherwise Xcode will not recognize that it is the start of an open bracket after text has been inputed.

Picture 9

Step 5:

Everything is done in our .h folder so now we can go to our .m folder and start up some heavy coding where we will action add the action code to make the pop up alert. After – (IBAction)alert  {  hit enter two times and you are going to input the code that I will show below.

UIAlertView *alert = [[UIAlertView allocinitWithTitle:@”Pop up Alert” message:@”POP UP TIME” delegate:nil cancelButtonTitle:@”Dismiss” otherButtonTitles:nil];

[alert show];

[alert release];

(the second line above should still be attaching after nil followed by a space however Wordpress doesn’t give me enough space)

Step 6:

Now that you are completely done with your application you can go File, Save and hit Build and Go and this is what your outcome of your application should come out to.

Picture 13

- Thanks

http://www.protocalldev.net FOR MORE XCODE TUTORIALS!

Reader Comments (4)

THANKS FOR SCREAMING AT ME

August 27, 2009 | Unregistered CommenterGuy

@Guy, sorry about that. I fixed Anthony's title.

August 27, 2009 | Registered CommenterAnn Smarty

Thanks David

August 27, 2009 | Unregistered CommenterGuy

My bad lol didnt notice that

August 27, 2009 | Registered CommenterAnthony

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>