Hi, i have made an alert view with 2 buttons one saying done and one saying donate. How do i link up the donate button to goto paypal.com? Here is my source code.
Code:
- (IBAction)aboutPressed:(id)sender;
{
UIAlertView *startAlert = [[UIAlertView alloc] initWithTitle:@"Information" message:@"If you have any problems with this application feel free to email me at sdk4you@gmail.com and please donate." delegate:nil cancelButtonTitle:@"Done" otherButtonTitles:@"Donate", nil];
[startAlert show];
[startAlert release];
}
It took Google 0.23 seconds to fine this thread. That's how you find out which button was pressed. Another stunning 0.18 seconds for Google to find out how to open URLs.
Cheers,
Bob
__________________ We are God’s middle children, according to Tyler Durden, with no special place in history and no special attention.
I don't quite understand. The first thread I linked to has sample code that you have to implement. Stitch's post explains what you need to do. What are you having problems with?
And more importantly, what have you tried? Why did it not work?
Cheers,
Bob
__________________ We are God’s middle children, according to Tyler Durden, with no special place in history and no special attention.
The method
- (void)alertViewUIAlertView *)actionSheet clickedButtonAtIndexNSInteger)buttonIndex { }
detects which button was pressed on your AlertView. You need to implement the delegate protocol in your header file (see Stitch's post in the linked thread). Depending on whether you "donate" button has index 0 or 1, you need to adjust the if-statement in alertView:clickedButtonAtIndex: to match your "donate" button.
I don't know what you are missing? What did you put the code? What does it stop working? You are not really giving me much information to work with here... I cannot read your mind or code that you didn't post here.
Cheers,
Bob
P.S.: Please use code-tags -- they make your code a lot easier to read.
__________________ We are God’s middle children, according to Tyler Durden, with no special place in history and no special attention.
#import "TimerAppDelegate.h"
@implementation TimerAppDelegate
- (IBAction)aboutPressed:(id)sender
{
UIAlertView *startAlert = [[UIAlertView alloc] initWithTitle:@"Information" message:@"If you have any problems with this application feel free to email me at sdk4you@gmail.com and please donate." delegate:self cancelButtonTitle:@"Done" otherButtonTitles:@"Donate" , nil];
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
}}
[startAlert show];
[startAlert release];
}
and i am getting the errors "alert view undeclared" and error expected ; before :
Quote:
Originally Posted by Robert Paulson
The method
- (void)alertViewUIAlertView *)actionSheet clickedButtonAtIndexNSInteger)buttonIndex { }
detects which button was pressed on your AlertView. You need to implement the delegate protocol in your header file (see Stitch's post in the linked thread). Depending on whether you "donate" button has index 0 or 1, you need to adjust the if-statement in alertView:clickedButtonAtIndex: to match your "donate" button.
I don't know what you are missing? What did you put the code? What does it stop working? You are not really giving me much information to work with here... I cannot read your mind or code that you didn't post here.
Cheers,
Bob
P.S.: Please use code-tags -- they make your code a lot easier to read.