• 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];
    
    }
  • 相关阅读:
    使用TestStack.White进行Windows UI的自动化测试
    基于IDEA的JavaWeb开发环境搭建
    hfish 集群蜜罐搭建
    HFish开源蜜罐搭建
    redis实现查找附近商户信息功能
    WIN10 HYPERV 1503
    RPC
    推荐一个聚合搜索引擎提高学习工作效率
    RocketMQ原理分析&场景问题
    《高性能利器》--异步调用实现原理详解!
  • 原文地址:https://www.cnblogs.com/flyingdreaming/p/UIActionSheet.html
Copyright © 2020-2023  润新知