首页 > 其他 > 详细

UISwitch 监听响应

时间:2016-01-26 20:28:40      阅读:207      评论:0      收藏:0      [点我收藏+]


    UISwitch *swh = [[UISwitch alloc]initWithFrame:CGRectMake(100,100, 50, 30)];
        swh.on = YES;
        [swh addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
        cell.accessoryView = swh;
        cell.textLabel.text = tableArr[indexPath.section];

//switch事件方法
-(void)switchAction:(id)sender
{
    UISwitch *switchButton = (UISwitch*)sender;
    BOOL btnSwh = [switchButton isOn];

    if (btnSwh) {
        UIAlertController * alertController = [UIAlertController alertControllerWithTitle: @"提示"
                                                                                  message: @"省流量模式已开启"
                                                                           preferredStyle:UIAlertControllerStyleAlert];
        
        [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:alertController animated:YES completion:nil];
    }
}

UISwitch 监听响应

原文:http://www.cnblogs.com/Bo-tree/p/5161327.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!