我有两个警报按钮,我不能让第二个按钮去到另一个URL,它只是去第一个按钮相同的URL。第二次警报弹出没有问题,第二次警报上的“访问”按钮与第一次警报相同。第二个AlertView openURL不起作用
-(IBAction)creditBtn: (id) sender{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Credits"
message:@"Message
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Visit", nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex==1) {
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:@"http://website1.com"]];
}
}
-(IBAction)sendBtn: (id) sender2{
UIAlertView *alert2 = [[UIAlertView alloc]
initWithTitle:@"Send Me Your Feedback"
message:@"Message"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Visit", nil];
[alert2 show];
[alert2 release];
}
- (void)alertView2:(UIAlertView *)alertView2 clickedButtonAtIndex:(NSInteger)buttonIndex{
// resign the shake FirstResponder, no keyboard if not
//[self resignFirstResponder];
// making the otherButtonTitles button in the alert open a URL
if(buttonIndex==0){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://website2.com"]];
}
}