我有兩個警報按鈕,我不能讓第二個按鈕去到另一個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"]];
}
}