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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 07-05-2010, 07:09 PM   #1 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default Help with alertView

Im trying to switch views with a alert view butt when i press the button it doesnt do anything please help my code is


Code:
- (IBAction)pop{
	
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You got hit!!" message:@"You lasted %d seconds" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:@"2", @"3",nil];
	[alert show];
	[alert release];
	
}

- (void)alert:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {

if (buttonIndex == 1) {
	
	
	viewTwo *gamesMenu = [[viewTwo alloc] initWithNibName:@"viewTwo" bundle:nil];
	gamesMenu.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
	[self presentModalViewController:gamesMenu animated:YES];
	[gamesMenu release];
	
}
}
BillyGiggles is offline   Reply With Quote
Old 07-05-2010, 07:26 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 14
KoolStar is on a distinguished road
Default

In your alertview you need to set the delegate to self if you want to use the delegate method of:
Code:
- (void)alert:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
Code:
- (IBAction)pop{
	
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You got hit!!" message:@"You lasted %d seconds" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"2", @"3",nil];
	[alert show];
	[alert release];
	
}
KoolStar is offline   Reply With Quote
Old 07-05-2010, 07:33 PM   #3 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

can you put the code up on how i would do that?


Thanks
BillyGiggles is offline   Reply With Quote
Old 07-05-2010, 08:03 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 14
KoolStar is on a distinguished road
Default

Code:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You got hit!!" message:@"You lasted %d seconds" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"2", @"3",nil];
KoolStar is offline   Reply With Quote
Old 07-05-2010, 08:58 PM   #5 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

It didnt do anything its still wont work any other ideas?
BillyGiggles is offline   Reply With Quote
Old 07-05-2010, 11:03 PM   #6 (permalink)
almostfunnydev
iPhone Dev SDK Supporter
 
rocotilos's Avatar
 
Join Date: Oct 2009
Age: 34
Posts: 3,015
rocotilos is on a distinguished road
Default

On top of my head, I think here is your problem:

"if (buttonIndex == 1)"

should be

if ([buttonIndex intValue] == 1)
rocotilos is offline   Reply With Quote
Old 07-06-2010, 11:39 AM   #7 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

hmm what is wrong with this that didnt work either it had 0 errors but 1 warning the warning is pn line

if ([buttonIndex intValue] == 1)

warning Omvalid receiver tpye NSInteger

any ideas

thanks
BillyGiggles is offline   Reply With Quote
Old 07-06-2010, 05:57 PM   #8 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 3
Chepe is on a distinguished road
Default

delegate:nil ---> wrong!
delegate:self --> will do

Chepe is offline   Reply With Quote
Old 07-07-2010, 09:08 AM   #9 (permalink)
Nerd.
 
Join Date: Jun 2010
Location: In a house
Posts: 458
BillyGiggles is on a distinguished road
Default

?? huh it still dont work it pops up with the buttons it just doesnt switch views when you hit the alert view button

any other ideas?
BillyGiggles is offline   Reply With Quote
Reply

Bookmarks

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: 329
7 members and 322 guests
anothermine, Chickenrig, givensur, iNet, michaelhansen, PixelInteractive, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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