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 10-09-2009, 11:32 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 22
Exclamation UIAlertView on launch!

Hello Everyone,

I am new to development on the iphone and ipod touch, and my first app is almost complete. The only thing I have to do is to make a UIAlertView on the first three lauches, but I am not sure how to do this! Here is the code I have so far, and it works great to make an alert on launch, but it pops up every time.

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {  
	 {
		alert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
		[alert show];
		[alert release];
	}
}

- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
	
	if (buttonIndex == 0) {
		
	}
    
    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}
Can anyone help me?
dsinc14 is offline   Reply With Quote
Old 10-09-2009, 11:44 PM   #2 (permalink)
iOS Developer
 
chaseacton's Avatar
 
Join Date: Feb 2009
Location: United States
Posts: 532
Send a message via AIM to chaseacton Send a message via Skype™ to chaseacton
Default

Quote:
Originally Posted by dsinc14 View Post
Hello Everyone,

I am new to development on the iphone and ipod touch, and my first app is almost complete. The only thing I have to do is to make a UIAlertView on the first three lauches, but I am not sure how to do this! Here is the code I have so far, and it works great to make an alert on launch, but it pops up every time.

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {  
	 {
		alert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
		[alert show];
		[alert release];
	}
}

- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
	
	if (buttonIndex == 0) {
		
	}
    
    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}
Can anyone help me?
I would make an NSInterger to have a count of 0 by default. Each time the app launches, you would add 1 to the count and save the count with NSUserDefaults on each close. Then set up your alert view to only be triggered on the first three launches like so:

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {  
	 {
if (count < 3){
		alert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
		[alert show];
		[alert release];
	}
}
else {

}
}

- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
	
	if (buttonIndex == 0) {
		
	}
    
    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}
__________________
Freelance Inquiries:
www.chaseacton.com/services

Apps:
chaseacton is offline   Reply With Quote
Old 10-09-2009, 11:56 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 22
Default

Quote:
Originally Posted by chaseacton View Post
I would make an NSInterger to have a count of 0 by default. Each time the app launches, you would add 1 to the count and save the count with NSUserDefaults on each close. Then set up your alert view to only be triggered on the first three launches like so:

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {  
	 {
if (count < 3){
		alert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
		[alert show];
		[alert release];
	}
}
else {

}
}

- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
	
	if (buttonIndex == 0) {
		
	}
    
    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}
Sorry But I don't understand what to do here "I would make an NSInterger to have a count of 0 by default. Each time the app launches, you would add 1 to the count and save the count with NSUserDefaults on each close." Can you explain it a little easier?
dsinc14 is offline   Reply With Quote
Old 08-12-2010, 10:49 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 47
Default

Just add an alert view code, in the viewDidLoad of the viewcontroller.m
john4mac is offline   Reply With Quote
Old 08-13-2010, 03:45 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Enschede, Netherlands
Posts: 198
Smile

put this in the .h:
Code:
BOOL alert;

@property (nonatomic, readonly) BOOL alert;
in the .m:
Code:
@synthesize alert;

if (alert == FALSE) {
//
//your alert view
//
alert = TRUE;
}
rickrets is offline   Reply With Quote
Reply

Bookmarks

Tags
alert, iphone sdk, pop

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: 248
23 members and 225 guests
ADY, Alsahir, beleg_1998, Dani77, diyora, FAED, fredidf, iDifferent, iph_s, JamesCahall, JasonR, mer10, prchn4christ, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, timle8n1, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,755
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

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