• iOS开发之APP推送设置WIFI


    在iOS开发过程中,有时需要连接网络。当访问请求,检测到网络不可用时,需要提示用户手动进行设置网络并告知用户操作路径设置可用的网络。

    只需一行代码即可实现:

    - (void)viewDidLoad {

        [super viewDidLoad];

        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

        button.backgroundColor = [UIColor redColor];

        button.frame = CGRectMake(50, 100, 100, 30);

        [self.view addSubview:button];

        [button addTarget:self action:@selector(pushSetting) forControlEvents:UIControlEventTouchUpInside]; 

    }

    - (void)pushSetting{

     NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"];

      BOOL isCanOpenURL = [[UIApplication  sharedApplication] openURL:url];//一行代码实现跳转

    }

    另补充:在项目中的info.plist中添加 URL types(NSArray) 并在item0(NSDictionary)中选出键为URL Schemes(NSArray),然后设置item0对应的值为prefs。或者直接在info项中的URL Types点击+直接设置URL Schemes

     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Restrictions"]];
    http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme

    List of currently known URLs in the Settings app:

    • prefs:root=General&path=About
    • prefs:root=General&path=ACCESSIBILITY
    • prefs:root=AIRPLANE_MODE
    • prefs:root=General&path=AUTOLOCK
    • prefs:root=General&path=USAGE/CELLULAR_USAGE
    • prefs:root=Brightness
    • prefs:root=General&path=Bluetooth
    • prefs:root=General&path=DATE_AND_TIME
    • prefs:root=FACETIME
    • prefs:root=General
    • prefs:root=General&path=Keyboard
    • prefs:root=CASTLE
    • prefs:root=CASTLE&path=STORAGE_AND_BACKUP
    • prefs:root=General&path=INTERNATIONAL
    • prefs:root=LOCATION_SERVICES
    • prefs:root=ACCOUNT_SETTINGS
    • prefs:root=MUSIC
    • prefs:root=MUSIC&path=EQ
    • prefs:root=MUSIC&path=VolumeLimit
    • prefs:root=General&path=Network
    • prefs:root=NIKE_PLUS_IPOD
    • prefs:root=NOTES
    • prefs:root=NOTIFICATIONS_ID
    • prefs:root=Phone
    • prefs:root=Photos
    • prefs:root=General&path=ManagedConfigurationList
    • prefs:root=General&path=Reset
    • prefs:root=Sounds&path=Ringtone
    • prefs:root=Safari
    • prefs:root=General&path=Assistant
    • prefs:root=Sounds
    • prefs:root=General&path=SOFTWARE_UPDATE_LINK
    • prefs:root=STORE
    • prefs:root=TWITTER
    • prefs:root=General&path=USAGE
    • prefs:root=VIDEO
    • prefs:root=General&path=Network/VPN
    • prefs:root=Wallpaper
    • prefs:root=WIFI
    • prefs:root=INTERNET_TETHERING
     
    提高技能如同提升自信心。
  • 相关阅读:
    在ASP.Net中两种利用CSS实现多界面的方法
    c# 添加图片水印,可以指定水印位置+生成缩略图[付上帅图1,2,3,4]
    精力有限,本博客暂停维护,转到www.80back.com(个人的小站)
    设计一个silverlight的Button控件silverlight(银光)学习(1)
    asp.net(c#)上传图片生成缩略图
    DataGrid和存储过程结合的分页,只读取当前页数据
    c#实现google样式的分页
    asp.net MD5加密函数(c#)
    执行JS
    LoadRunner常见问题
  • 原文地址:https://www.cnblogs.com/chims-liu-touch/p/5328430.html
Copyright © 2020-2023  润新知