• IOSActionSheet、AlertView、Slider、Switch的简单使用


    ActionSheet、AlertView、Slider、Switch的简单使用方法如下:

    - (IBAction)buttonPressed:(id)sender {
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure" delegate:self cancelButtonTitle:@"No way" destructiveButtonTitle:@"Yes,I'm sure!" otherButtonTitles:@"Other button", nil];
        [actionSheet showInView:self.view];
        [actionSheet release];
    }

    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
    {
        if (buttonIndex != [actionSheet cancelButtonIndex]) {
            NSString *msg = nil;
            msg = [[NSString alloc] initWithFormat:@"You can breathe easy, %@ everything went OK.",textFieldName.text];
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Something was done" message:msg delegate:self cancelButtonTitle:@"guo" otherButtonTitles: nil];
            [alert show];
            [alert release];
            [msg release];
        }
    }

    - (IBAction)sliderChanged:(id)sender {              //slider的滑动显示label
        UISlider *slider = (UISlider *)sender;
        int progressAsInt = (int)(slider.value + 0.5f);
        NSString *newText = [[NSString alloc] initWithFormat:@"%d",progressAsInt];
        labelSlider.text = newText;
        [newText release];
    }

    - (IBAction)switchChanged:(id)sender {            //switch选择改变
        UISwitch *whichSwitch = (UISwitch *)sender;
        BOOL setting = whichSwitch.isOn;
        [leftSwitch setOn:setting animated:YES];
        [rightSwitch setOn:setting animated:YES];
    }

  • 相关阅读:
    Flutter 路由管理
    SpringMVC 集成 MyBatis
    关于windows下安装mysql数据库出现中文乱码的问题
    md5.digest()与md5.hexdigest()之间的区别及转换
    MongoDB基础命令及操作
    redis相关操作&基本命令使用
    python中mysql主从同步配置的方法
    shell入门基础&常见命令及用法
    ORM总结
    多任务:进程、线程、协程总结及关系
  • 原文地址:https://www.cnblogs.com/tx8899/p/2536423.html
Copyright © 2020-2023  润新知