以编程方式取消UIAlertView

ato*_*nda 7 iphone cocoa alert objective-c uialertview

如何以UIAlertView编程方式取消?这是我用来显示UIAlertView的代码

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Save Background" message:@"Downloading..." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
    CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 70.0);
    [myAlertView setTransform:myTransform];
    [myAlertView show];
Run Code Online (Sandbox Code Playgroud)

Jus*_*Boo 11

尝试使用dismissWithClickedButtonIndex:这样:

这是要使用的代码:

[myAlertView dismissWithClickedButtonIndex:-1 animated:YES];
Run Code Online (Sandbox Code Playgroud)