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];
    
    }
  • 相关阅读:
    简单方法实现无刷新提交Form表单
    [LeetCode] 654. Maximum Binary Tree
    [LeetCode]3. Longest Substring Without Repeating Characters
    《设计模式之禅》读书笔记(四)之抽象工厂模式
    《设计模式之禅》读书笔记(三)之扩展工厂方法模式
    《设计模式之禅》读书笔记(二)之工厂方法模式
    《将博客搬至CSDN》
    php解析excel文件
    git 删除分支
    git 修改注释信息
  • 原文地址:https://www.cnblogs.com/flyingdreaming/p/UIActionSheet.html
Copyright © 2011-2022 走看看