zoukankan      html  css  js  c++  java
  • UIAlertView 与 UIActionSheet (提示用户)的使用方法

    UIAlertView 提示用户  帮助用户选择框 

    //    UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"警告" message:@"你还没把信息填完" delegate:nil  cancelButtonTitle:@"cancle" otherButtonTitles:@"确认",  nil];

    //    [alterView show];

    //    [alterView release];

        

          AlterView *alterView = [[AlterView alloc] initWithTitle:@"警告" message:@"你还没把信息填完" delegate:self

                    cancelButtonTitle:@"cancle" otherButtonTitles:@"确认",@"再次确认" , nil];

        alterView.tag=identifier;

        [alterView release];

        identifier++;

     /**

    title:视图标题

    delegate:设置代理

    cancelButtonTitle:取消按钮的标题

    destructiveButtonTitle:特殊标记的按钮的标题

    otherButtonTitles:其他按钮的标题

    */

    UIActionSheet *actionSheet =[[UIActionSheet alloc]initWithTitle:@"提示" delegate:self  cancelButtonTitle:@"cancel" destructiveButtonTitle:@"标题 //强调的 otherButtonTitles:@"选择1", @"选择2",@"选择3",nil];

        [actionSheet showInView:self.window];

     

        [actionSheet release];

    二、常用方法和属性介绍

    @property(nonatomic,copy) NSString *title;

    设置标题

    @property(nonatomic) UIActionSheetStyle actionSheetStyle;

    设置风格,枚举如下:

    1
    2
    3
    4
    5
    6
    typedef NS_ENUM(NSInteger, UIActionSheetStyle) {
        UIActionSheetStyleAutomatic        = -1,      
        UIActionSheetStyleDefault          = UIBarStyleDefault,
        UIActionSheetStyleBlackTranslucent = UIBarStyleBlackTranslucent,
        UIActionSheetStyleBlackOpaque      = UIBarStyleBlackOpaque,
    };

    - (NSInteger)addButtonWithTitle:(NSString *)title;

    添加一个按钮,会返回按钮的索引

    - (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;

    获取按钮标题

    @property(nonatomic,readonly) NSInteger numberOfButtons;

    获取按钮数量

    @property(nonatomic) NSInteger cancelButtonIndex;

    设置取消按钮的索引值

    @property(nonatomic) NSInteger destructiveButtonIndex;

    设置特殊标记

    @property(nonatomic,readonly,getter=isVisible) BOOL visible;

    视图当前是否可见

    下面是几种弹出方式,会根据风格不同展现不同的方式

    - (void)showFromToolbar:(UIToolbar *)view;

    - (void)showFromTabBar:(UITabBar *)view;

    - (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated ;

    - (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated ;

    - (void)showInView:(UIView *)view;

    - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;

    使用代码将视图收回

    三、UIActionSheet代理方法

    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;

    点击按钮时触发的方法

    - (void)willPresentActionSheet:(UIActionSheet *)actionSheet; 

    视图将要弹出时触发的方法

    - (void)didPresentActionSheet:(UIActionSheet *)actionSheet;

    视图已经弹出式触发的方法

    - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex;

    点击按钮后,视图将要收回时触发的方法

    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;

    点击按钮后,视图已经收回时触发的方法

  • 相关阅读:
    C#.Net Winform 应用程序莫名其妙崩溃。
    不小心点击安装了搜狗手机助手,顿时有一种草搜狗全体人员的感觉。
    家乐福张江店班车时刻表
    为什么学习设计模式
    同一端口如何区分不同的Socket
    用命令行CMD .bat 相关操作 如: 创建快捷方式 复制文件等
    C++ 时间获取和时间测量
    get all ODBC drivers 驱动
    命令行 编译C#.NET项目
    如何打开.hlp文件指定的topic
  • 原文地址:https://www.cnblogs.com/meixian/p/5370890.html
Copyright © 2011-2022 走看看