iOS button点击事件问题

iOS 码拜 9年前 (2015-11-16) 1734次浏览
– (IBAction)pressBtn:(UIButton *)sender {
    
    switch (sender.tag)
    {
        case 0://创建VPN描述文件
        {
            [[NEVPNManager sharedManager] loadFromPreferencesWithCompletionHandler:^(NSError *error){
                if(error)
                {
                    NSLog(@”加载偏好设置失败!   Load error: %@”, error);
                }
                else
                {
                    //配置IPSec
                    [self setupIPSec];
                    
                    //保存VPN到系统->通用->VPN->个人VPN
                    [[NEVPNManager sharedManager] saveToPreferencesWithCompletionHandler:^(NSError *error){
                        if(error)
                        {
                            ALERT(@”保存VPN配置信息失败”, error.description);
                            NSLog(@”保存VPN配置信息失败!Save error: %@”, error);
                        }
                        else
                        {
                            NSLog(@”Saved!”);
                            ALERT(@”Saved”, @”保存VPN配置信息 Success!”);
                        }
                    }];
                }
            }];
            break;
        }
        case 3://TODO:断开VPN
        {
            [[NEVPNManager sharedManager] loadFromPreferencesWithCompletionHandler:^(NSError *error){
                if (!error)
                {
                    [[NEVPNManager sharedManager].connection stopVPNTunnel];
                }else{
                    NSLog(@”加载偏好设置失败!   Load error: %@”, error);
                }
            }];
            break;
        }
        case 2://TODO:连接VPN(前提是必须有描述文件)
        {
            [[NEVPNManager sharedManager] loadFromPreferencesWithCompletionHandler:^(NSError *error){
                if (!error)
                {
                    //配置IPSec
                    [self setupIPSec];
                    
                    [[NEVPNManager sharedManager].connection startVPNTunnelAndReturnError:&error];
                }else{
                    NSLog(@”加载偏好设置失败!   Load error: %@”, error);
                }
            }];
            break;
        }
            
        default:
            break;
    }
    
    iOS button点击事件问题
}
解决方案:100分
初始btn.seletced = NO;
点击事件
if(!btw.seletecd)
{
  //配置文件  链接
}
else
{
  //断开链接
}
btn.seletced = !btn.seletced;

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明iOS button点击事件问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)