IOS學習筆記(四)AlertView

來源:互聯網
上載者:User

標籤:

【轉】   

alertView     有兩個button時,一般預設使左邊的是取消,右邊的是確認。蘋果習慣~

alertView 的屬性是可以設定的。   [AlertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];     <

UIAlertView *alertView = [UIAlertView alloc] initWithTitle:@"DefaultAlertView"message:@"Defalut" 

                                      delegate:self cancelButtonTitle:@"Cancel" 

                                 otherButtonTitles:@"OK", nil];   <

顯示alertView            [alertView show];   <

代理方法     

      按index索引點擊事件,index從0開始          - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex                           這個方法在動畫結束和視圖隱藏之後調用  - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex                             這個方法在動畫開始和視圖隱藏之前調用      - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex                在視圖將要被取消之前          - (void)alertViewCancel:(UIAlertView *)alertView                                      在視圖提交給使用者以後調用                       - (void)didPresentAlertView:(UIAlertView *)alertView                                              

 

           設定yes / no  將會設定alertView 的第一個otherButton的enable屬性   - (BOOL)alertViewShouldEnableFirstOtherButton(UIAlertView *)alertView

 

    這六個delegate 方法調用的順序依次是    alertViewShouldEnableFirstOtherButton    willPresentAlertView     didPresentAlertView     clickedButtonAtIndex     willDismissWithButtonIndex(如果會觸發視圖取消,則會調用alertViewCancel)     didDismissWithButtonIndex ios4.0以後 alertView不會自動隨著程式轉向後台而移除alertView屬性1.alertViewStyle:只彈資訊和按鈕        UIAlertViewStyleDefault 有一個textfield加密框     UIAlertViewStyleSecureTextInput 有一個不加密的      textfieldUIAlertViewStylePlainTextInput 有兩個textfield,     Login和passwordUIAlertViewStyleLoginAndPasswordInput  只要有textfield就可以用textfieldAtIndex來捕獲並進行相應的操作例如換鍵盤類型 2.cancelButtonIndex     開始是0,如果沒有設定cancel button 則是-1 3.delegate        如果沒有設定則是nil 4.firstOtherButtonIndex    從0開始,如果沒設定則是-1,而且沒被設定則會被忽略 5.message           訊息 6.numberOfButtons          唯讀  alertView中的按鈕數量 7.title           標題 8.visible         唯讀  如果是yes 表示被顯示 執行個體方法傳回值是增加的Button的index              - (NSInteger)addButtonWithTitle:(NSString *)title 輸入buttonIndex 返回button的標題      - (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex程式自動完成點擊buttonIndex的button 並dismiss 整個alertView的操作                        - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated要顯示必須要調用這個alertview才會顯示  - (void)show 傳回值是textfield          -  (UITextField *)textfieldAtIndex:(NSInteger)textfieldIndexUIAlertViewStyleDefault 沒有UIAlertViewStyleSecureInput textfieldIndex 只有一個為0UIAlertViewStylePlainInput textfieldIndex 只有一個為0UIAlertViewStyleLoginAndPasswordInput textfieldIndex有兩個 0 1

 

IOS學習筆記(四)AlertView

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.