Reputation: 484
all
it will show a UIAlertView when i click a button on the view
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Will you?"
message:@"will you go there?"
delegate:self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes" nil];
i want to give two selector to the two button,when i click the 'NO' button,do nothing,but just close this alertview,if i click the Yes button,that means i choose a selector called 'donextthing' , so how can i do?thanks
Upvotes: 0
Views: 682
Reputation: 506
In your .h add the UIAlertViewDelegate, something like this:
@interface yourView : UIViewController <UIAlertViewDelegate> {
And in your .m add this after your UIAlertView:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *alertIndex = [alertView buttonTitleAtIndex:buttonIndex];
if([alertIndex isEqualToString:@"Yes"])
{
//Do something
}
}
Upvotes: 2