UIAlertView *alertView = [[UIAlertViewalloc] initWithTitle:@"title"message:@""delegate:selfcancelButtonTitle:@"cancel"otherButtonTitles:@"other",nil];
[alertView show];
用到代理方法时要添加协议
#pragma mark - UIAlertView Delegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"index %d",buttonIndex);
}