打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
ActionSheet、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];
}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
xmpp 带内注册
不使用IB在UIWebView里面扩展添加UIMenuItem菜单
IOS之数据持久化
UIActionSheet的使用和系统相机的相关调用
TTTAttributedLabel 使用方法
iOS 各种传值方式
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服