UIAlertView

UIAlertView

  • 继承自UIView
  • IOS9后苹果不再建议使用UIAlertView,而是使用UIAlertController(IOS8推出),因此要注意版本适配

UIAlertView的使用实现指示器效果

- (void)useAlertView
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"警告" message:@"是否要删除它?" delegate:self cancelButtonTitle:@"是" otherButtonTitles:@"否", nil];
    alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    alertView.tag = 999;    // 一般要作标记,在clickedButtonAtIndex中根据tag作不同的处理
    [alertView show];
}

#pragma mark - 
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
            if (alertView.tag == 999) {
                 NSLog(@"点击了第%zd个按钮 - %@", buttonIndex, [alertView textFieldAtIndex:0].text);
                 return;
            }
    }
}

你可能感兴趣的:(UIAlertView)