溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

IOS中如何實現彈框

發布時間:2021-07-08 14:32:16 來源:億速云 閱讀:186 作者:小新 欄目:移動開發

這篇文章主要介紹了IOS中如何實現彈框,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

IOS 中彈框的實現方法整理

#define iOS8Later ([UIDevice currentDevice].systemVersion.doubleValue >= 8.0)

ios 8以前的彈框

@interface RootViewController ()<UIAlertViewDelegate> 
 
@end
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"登陸失敗" message:@"請重新輸入用戶名和密碼" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil]; 
      [alert show];
#pragma mark - UIAlertView Delegate Methods - 
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
  if(buttonIndex == 0) 
  { 
    NSLog(@"點擊取消按鈕后,想要的操作,可以加此處"); 
  } 
  else if(buttonIndex == 1) 
  { 
    NSLog(@"點擊確定按鈕后,想要的操作,可以加此處"); 
  } 
}

ios8以后的彈框

  UIAlertController *_alertVC = [UIAlertController alertControllerWithTitle:@"登陸失敗" message:@"請重新輸入用戶名和密碼" preferredStyle:UIAlertControllerStyleAlert]; 
       
      //警告類型,紅色字體 UIAlertActionStyleDestructive 
//      UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDestructive handler:nil]; 
//      [_alertVC addAction:_doAction]; 
       
      UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) 
      { 
        NSLog(@"點擊確定按鈕后,想要的操作,可以加此處"); 
      }]; 
      [_alertVC addAction:_doAction]; 
 
//      UIAlertAction *_cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]; 
//      [_alertVC addAction:_cancleAction]; 
       
      UIAlertAction *_cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) 
      { 
        NSLog(@"點擊取消按鈕后,想要的操作"); 
      }]; 
      [_alertVC addAction:_cancleAction]; 
       
      [self presentViewController:_alertVC animated:YES completion:nil];
//警告類型,紅色字體 UIAlertActionStyleDestructive,如下圖所示的效果

      UIAlertAction *_doAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDestructive handler:nil];

      [_alertVC addAction:_doAction];

IOS中如何實現彈框

感謝你能夠認真閱讀完這篇文章,希望小編分享的“IOS中如何實現彈框”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!

向AI問一下細節
推薦閱讀:
  1. js選擇彈框
  2. layer彈框

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

ios
AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女