iOS開發:UIAlertView

weixin_30488085發表於2020-04-06
之前看過幾種UIAlertView的使用,現總結一下,圖片來至紅黑聯盟;

1.基本用法


1 UIAlertView *view = [[UIAlertView alloc]initWithTitle:@"Test"    //標題
2                                               message:@"this is a alert view "   //顯示內容
3                                              delegate:nil          //委託,可以點選事件進行處理
4                                     cancelButtonTitle:@"取消"
5                                     otherButtonTitles:@"確定"
6                                                     //,@"其他",    //新增其他按鈕 
7                                  nil];


\

2.多個按鈕  

取消上面程式碼@“其他”的註釋後,執行效果如下

 

\

3.一些系統樣式引數

UIAlertViewStyle這個列舉提供了幾個樣式

1 typedef NS_ENUM(NSInteger, UIAlertViewStyle) {
2     UIAlertViewStyleDefault = 0,            //預設樣式
3     UIAlertViewStyleSecureTextInput,         //密文輸入框
4     UIAlertViewStylePlainTextInput,          //明文輸入框
5     UIAlertViewStyleLoginAndPasswordInput      //登入用輸入框,有明文使用者名稱,和密文密碼輸入二個輸入框
6 };

使用程式碼如下:


1     UIAlertView *view = [[UIAlertView alloc]initWithTitle:@"請等待"    //標題
2                                                   message:@"this is a alert view "   //顯示內容
3                                                  delegate:nil                //委託,可以點選事件進行處理
4                                         cancelButtonTitle:@"取消"
5                                         otherButtonTitles:@"確定",
6                                               

轉載於:https://www.cnblogs.com/devZhou/p/4872697.html

相關文章