zoukankan      html  css  js  c++  java
  • Cocoa touch(八):UIAlertView

     @interface UIAlertView : UIView 
    
    - (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id /*<UIAlertViewDelegate>*/)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
    
     
    
    @property(nonatomic,assign) id/*<UIAlertViewDelegate>*/ delegate;    // weak reference
    
    @property(nonatomic,copy) NSString *title;
    
    @property(nonatomic,copy) NSString *message;   // secondary explanation text
    
    - (NSInteger)addButtonWithTitle:(NSString *)title;    // returns index of button. 0 based.
    
    - (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;
    
    @property(nonatomic,readonly) NSInteger numberOfButtons;
    
    @property(nonatomic) NSInteger cancelButtonIndex;      // if the delegate does not implement -alertViewCancel:, we pretend this button was clicked on. default is -1
    
     
    
    @property(nonatomic,readonly) NSInteger firstOtherButtonIndex;// -1 if no otherButtonTitles or initWithTitle:... not used
    
    @property(nonatomic,readonly,getter=isVisible) BOOL visible; 
    
    // shows popup alert animated.
    
    - (void)show;
    
     
    
    // hides alert sheet or popup. use this method when you need to explicitly dismiss the alert.
    
    // it does not need to be called if the user presses on a button
    
    - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
    
     
    
    // Alert view style - defaults to UIAlertViewStyleDefault
    
    @property(nonatomic,assign) UIAlertViewStyle alertViewStyle NS_AVAILABLE_IOS(5_0);
     
    
    /* Retrieve a text field at an index - raises NSRangeException when textFieldIndex is out-of-bounds. 
    
       The field at index 0 will be the first text field (the single field or the login field), the field at index 1 will be the password field. */
    
    - (UITextField *)textFieldAtIndex:(NSInteger)textFieldIndex NS_AVAILABLE_IOS(5_0); 
    
    @end
    @protocol UIAlertViewDelegate <NSObject>
    @optional
    
    // Called when a button is clicked. The view will be automatically dismissed after this call returns
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
    
    // Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
    // If not defined in the delegate, we simulate a click in the cancel button
    - (void)alertViewCancel:(UIAlertView *)alertView;
    
    - (void)willPresentAlertView:(UIAlertView *)alertView;  // before animation and showing view
    - (void)didPresentAlertView:(UIAlertView *)alertView;  // after animation
    
    - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex; // before animation and hiding view
    - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;  // after animation
    
    // Called after edits in any of the default fields added by the style
    - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView;
    
    @end
    UIAlertView *alertView = [UIAlertView alloc] initWithTitle: @"Hello world"
    message: @"Do you agree"
    delete: self
    cacelButtonTitle: @"Cancel"
    otherButtonTitles: @"NO", @"YES", nil];
    alertView.alertViewStyle = NSAlertViewStyleDefault;
    [alertView show];
    typedef NS_ENUM(NSInteger, UIAlertViewStyle) {
        UIAlertViewStyleDefault = 0,
        UIAlertViewStyleSecureTextInput,
        UIAlertViewStylePlainTextInput,
        UIAlertViewStyleLoginAndPasswordInput
    };
  • 相关阅读:
    WordPress搭建的新博客 www.douzujun.club
    调用weka模拟实现 “主动学习“ 算法
    危险!80% 用户正在考虑放弃 Oracle JDK…
    最新!Dubbo 远程代码执行漏洞通告,速度升级
    Tomcat 又爆出高危漏洞!!Tomcat 8.5 ~10 中招…
    Spring Boot 启动,1 秒搞定!
    为什么要重写 hashcode 和 equals 方法?
    详解 Java 中 4 种 IO 模型
    详解GaussDB bufferpool缓存策略,这次彻底懂了!
    【API进阶之路6】一个技术盲点,差点让整个项目翻车
  • 原文地址:https://www.cnblogs.com/iprogrammer/p/3252395.html
Copyright © 2011-2022 走看看