zoukankan      html  css  js  c++  java
  • iOS UIActionSheet

    想要用 UIActionSheet必须现在 .h文件中加个协议  

    <UIActionSheetDelegate>

    这时操作表

    //定义一个操作表
    - (IBAction)uisheel:(id)sender {
        UIActionSheet *action=[[UIActionSheet alloc] initWithTitle:@"who!!!" delegate:self cancelButtonTitle:@"yes" destructiveButtonTitle:@"no" otherButtonTitles:@"yes or no", nil];
        
        [action showInView:self.view];
        [action release];
    }
    
    
    
    //先从一个事件中调用操作表
    
    - (void)actionSheetCancel:(UIActionSheet *)actionSheet
    {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"actionSheetCancel1 you" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];//声明操作表
        [v show];//执行操作表
        [v release];//释放操作表
    }
    
    // Called when a button is clicked. The view will be automatically dismissed after this call returns
    //但我们点击操作表按钮时出发的事件
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        //buttonIndex判断我们点击的时那个按钮,我们在设置的第一个的buttonIndex的数字时1,第二个时2.。。。
        if (buttonIndex==0) {
            UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am Number one" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
            [v show];
            [v release];
        }
        else if (buttonIndex==1) {
            UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am number Two" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
            [v show];
            [v release];
        }
        else {
            UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"I am number threeth" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
            [v show];
            [v release];
        }
    
    }
    
    //Called when a button is clicked. The view will be automatically dismissed after this call returns
    //显示视图之前调用
    - (void)willPresentActionSheet:(UIActionSheet *)actionSheet // before animation and showing view 1 7
    {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"第1次和最后一次" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    
    }
    // 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)didPresentActionSheet:(UIActionSheet *)actionSheet;  // after animation 2 6
    {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"第二次和第6次" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    
    }
    //动画前和隐藏视图前调用
    - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex
    // before animation and hiding view3 5
    {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"第3次和第5次" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    
    }
    //动画之后调用
    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
    // after animation 4
    {
        UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"nihao" message:@"第4次" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"no", nil];
        [v show];
        [v release];
    
    }
  • 相关阅读:
    tomcat使用不同的jdk版本 liunx 装两个jdk
    接下来自己的研究对象
    钉钉小程序开发的所有坑
    java 在web应用中获取本地目录和服务器上的目录不一致的问题
    Python2.7更新pip:UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 7: ordinal not in range(128)
    vue项目中禁止移动端双击放大,双手拉大放大的方法
    JZ56 删除链表中重复的结点
    JZ55 链表中环的入口结点
    JZ54 字符流中第一个不重复的字符
    JZ53 表示数值的字符串
  • 原文地址:https://www.cnblogs.com/flyingdreaming/p/UIActionSheet.html
Copyright © 2011-2022 走看看