zoukankan      html  css  js  c++  java
  • UIAlertView和UIActionSheet

    一、UIAlertView

    UIAlertView * alert=[[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];

    二、UIAlertView的代理方法

    @interface ViewController : UIViewController<UIAlertViewDelegate>

    @end  

    1、 //根据被点击按钮的索引处理点击事件  

      -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex  

         {    NSLog(@"clickButtonAtIndex:%d",buttonIndex); }

     2、  //AlertView已经消失时执行的事件  

        -(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex  

       {    NSLog(@"didDismissWithButtonIndex");  }  

     3、//ALertView即将消失时的事件  

      -(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex  

       {   NSLog(@"willDismissWithButtonIndex");   }  

     4、//AlertView的取消按钮的事件  

       -(void)alertViewCancel:(UIAlertView *)alertView  

        {   NSLog(@"alertViewCancel");   }  

    5、//AlertView已经显示时的事件  

      -(void)didPresentAlertView:(UIAlertView *)alertView  

       {    NSLog(@"didPresentAlertView");   }  

    6、//AlertView即将显示时  

       -(void)willPresentAlertView:(UIAlertView *)alertView  

       {    NSLog(@"willPresentAlertView");    }  

    三、UIActionSheet

    UIActionSheet * sheet=[[UIActionSheet alloc]initWithTitle:@"您要拨打哪个电话?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"0731-89786224" otherButtonTitles:@"400-1808-178", nil];
    [sheet showInView:self.view];

    四、UIActionSheet代理方法

    1、//根据被点击按钮的索引处理点击事件  

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

    {  }

    2、//ActionSheet的取消按钮的事件 

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

    3、//ActionSheet即将显示时  

    - (void)willPresentActionSheet:(UIActionSheet *)actionSheet; // before animation and showing view

    4、//ActionSheet已经显示时的事件  
    - (void)didPresentActionSheet:(UIActionSheet *)actionSheet; // after animation

    5、//ActionSheet即将消失时的事件  

    - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex; // before animation and hiding view

    6、 //ActionSheet已经消失时执行的事件  
    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex; // after animation

    五、二者的区别

    UIActionSheet用于迫使用户在两个或更多的选项之间进行选择的模式视图。操作表是从屏幕底部弹出,显示一系列按钮供用户选择,用户只有单击一个按钮后才能继续使用应用程序。(可以理解为桌面应用系统的右键菜单的功能)

    UIAlertView警告默认是以蓝色圆角矩形形式显示在屏幕中央,警告框可显示一个或多个按钮。

  • 相关阅读:
    web 开发之酷炫--- 酷炫展示
    攻城狮的体检
    科技发烧友之智能路由
    科技发烧友之3d吉米投影
    科技发烧友之单反佳能700d中高端
    上海
    视频会议
    机器学习之信息
    filter
    centos 20T硬盘(超过16T)分区
  • 原文地址:https://www.cnblogs.com/momosmile/p/4635289.html
Copyright © 2011-2022 走看看