Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-29-2009, 06:27 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 54
Default UIBarButtonItem and UIAlertView

Hey,

I'd like to know how to make an UIAlertView pop up when someone touches on an UIBarButtonItem.

Thanks.
nenos is offline   Reply With Quote
Old 01-29-2009, 06:32 PM   #2 (permalink)
Tutorial Author
 
Steaps's Avatar
 
Join Date: Oct 2008
Location: Ontario, Canada
Posts: 466
Default

Create the button and name it whatever. Add a new action. Create an AlertView inside the action, like so.
Code:
- (IBAction)actionName {
    UIAlertView *aboutScreen = [[UIAlertView alloc] initWithTitle:@"About" message:@"(C) Froot\nThis app was made by..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
	[aboutScreen show];
}
Steaps is offline   Reply With Quote
Old 01-29-2009, 07:17 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 54
Default

Thanks Steaps,

Sorry I'm new to development. How do I connect the action in Interface Builder to the button?
nenos is offline   Reply With Quote
Old 01-29-2009, 07:49 PM   #4 (permalink)
Tutorial Author
 
Steaps's Avatar
 
Join Date: Oct 2008
Location: Ontario, Canada
Posts: 466
Default

Quote:
Originally Posted by nenos View Post
Thanks Steaps,

Sorry I'm new to development. How do I connect the action in Interface Builder to the button?
Oh i'm new too, trust me . That was just one of the things i actually know how to do. Anyways:

First, you create a new action like so (Click the little +):


Second switch tabs to the second tab, then drag from here to there:

Then File -> Write Class Files

Then in your class files, go to the "<YourView>.m" file and the action will be there, paste this:
Code:
    UIAlertView *aboutScreen = [[UIAlertView alloc] initWithTitle:@"About" message:@"(C) Froot\nThis app was made by..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
	[aboutScreen show];
        [aboutScreen release];
Inside the action, and there you go.

Last edited by Steaps; 01-30-2009 at 04:02 PM.
Steaps is offline   Reply With Quote
Old 01-29-2009, 10:49 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 54
Default

Thanks heaps Steaps

works perfectly
nenos is offline   Reply With Quote
Old 01-29-2009, 11:20 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 145
Default

Make sure you do

Code:
[aboutScreen release];
when you're done with it
ambiensignal is offline   Reply With Quote
Old 01-29-2009, 11:39 PM   #7 (permalink)
Tutorial Author
 
Steaps's Avatar
 
Join Date: Oct 2008
Location: Ontario, Canada
Posts: 466
Default

Quote:
Originally Posted by ambiensignal View Post
Make sure you do

Code:
[aboutScreen release];
when you're done with it
I had that in there, not sure why i removed it, oh well.
Steaps is offline   Reply With Quote
Old 01-30-2009, 01:39 AM   #8 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 54
Default

oh ok thank you very much
nenos is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, uialertview, uibarbuttonitem

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 235
15 members and 220 guests
@sandris, ADY, Alsahir, dacapo, Dani77, djohnson, HemiMG, jansan, JasonR, MarkC, mer10, prchn4christ, ryandb2, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:00 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0