Question

is it possible (if yes how) to be able to send a tweet by pressing OtherButtonTitles button in a UIAlertView?

My code does a calculation upon a button press in "IBAction" and returns the result in a string as the "message" in "UIAlertView". i would like to add a second button, in "OtherButtonTitles", which when click will bring up the native tweeting page. but i dunno how to link the button to send a tweet.

    else{

    NSString *str = [[NSString alloc] initWithFormat:@"You require an average GPA of at least %.2f to achieve your Goal of %@", gpagoal, (NSString *)[myPickerDelegate.myGoal objectAtIndex: [myPicker selectedRowInComponent:0]]]; 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Nothing is Impossible" 
                                                    message:str 
                                                   delegate:self 
                                          cancelButtonTitle:@"Good Luck" 
                                          otherButtonTitles:@"Tweet",nil];

    //show alert
    [alert show];
    [alert release];
    NSLog(@"All Valid");
}

should it be something like

otherButtonTitles:@"Tweet", [self sendEasyTweet:(something here, dunno what to add)]];

"- (IBAction)sendEasyTweet:(id)sender" is a method i made to call up the tweeter composer with a standalone button. but due to the design of the app, i would like the tweeter button to be shown with the UIAlertView and not as a standalone.

Was it helpful?

Solution

It is, but you cannot set it directly. You have to implement the UIAlertViewDelegate and catch the method that gets executed when a button is pressed.

UIAlertViewDelegate protocol (look for – alertView:clickedButtonAtIndex:)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top