As per Duncan's answer you can use delegate and get which button is clicked.so on specific button's tap you can redirect to facebook page using below code.
UIAlertView *info = [[UIAlertView alloc]initWithTitle:@"Yup" message:@"You've won! Like Us on Facebook too" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Facebook", nil];
info.tag = 10;
[info show];
So when the user presses the Facebook button the delegate method alertView:clickedButtonAtIndex
will be called so at that time check alert.tag and then check if facebook button is tapped then show another alert.
Your Delegate Method should be
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == 10)
{
switch (buttonIndex) {
case 0:
NSLog(@"Cancel");
break;
case 1:
NSLog(@"Facebook");
[self showAlertForRedirect];
break;
default:
break;
}
}
else if (alertView.tag == 20)
{
switch (buttonIndex) {
case 0:
NSLog(@"Cancel");
break;
case 1:
NSLog(@"OK");
[self RedirectNow];
break;
default:
break;
}
}
}
-(void)showAlertForRedirect
{
UIAlertView *info2 = [[UIAlertView alloc]initWithTitle:@"Note" message:@"Would you like to redirect on facebook?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
info2.tag = 20;
[info2 show];
}
-(void)RedirectNow
{
NSURL *fanPageURL = [NSURL URLWithString:@"fb://profile/yourid"];
if (![[UIApplication sharedApplication] openURL: fanPageURL])
{
NSURL *webURL = [NSURL URLWithString:@"https://www.facebook.com/yourpagename"];
[[UIApplication sharedApplication] openURL: webURL];
}
}