应用跳转到系统设置里的各种设置界面
来源:互联网 发布:python数据分析书籍 编辑:程序博客网 时间:2024/05/17 14:27
1、在项目中的info.plist中添加URL Types并设置一项URL Schemes为prefs.如下图:
2、代码。比较多,在两个viewController中写的
#import "ViewController.h"#import "SecondViewController.h"#import <Masonry.h>@interface ViewController ()@property(nonatomic,retain) NSArray *kJumpArr;@property(nonatomic,retain) NSArray *kUrlArr;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; [self uiConfig];}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning];}-(void)uiConfig{ self.view.backgroundColor=[UIColor whiteColor]; self.edgesForExtendedLayout=UIRectEdgeNone; UIBarButtonItem *rightItem=[[UIBarButtonItem alloc] initWithTitle:@"next" style:UIBarButtonItemStylePlain target:self action:@selector(rightItemAction)]; self.navigationItem.rightBarButtonItem=rightItem; CGFloat topSpace=((self.view.frame.size.height-64)-[self.kJumpArr count]*10-([self.kJumpArr count]-1)*15)/2; for (int i=0;i<[self.kJumpArr count]; i++) { UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom]; [btn setTitle:self.kJumpArr[i] forState:UIControlStateNormal]; [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; [btn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted]; btn.tag=10+i; [btn addTarget:self action:@selector(butttonAction:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; [btn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.view.mas_top).offset(topSpace+i*25); make.height.mas_equalTo(10); make.centerX.equalTo(self.view.mas_centerX); make.width.mas_equalTo(300); }]; }}-(void)butttonAction:(UIButton *)button{ NSInteger num=button.tag-10; NSURL *url=[NSURL URLWithString:self.kUrlArr[num]]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; }}-(void)rightItemAction{ SecondViewController *VC=[[SecondViewController alloc] init]; [self.navigationController pushViewController:VC animated:YES];}-(NSArray *)kJumpArr{ if (_kJumpArr==nil) { _kJumpArr=@[@"Brightness",@"Bluetooth",@"Date&Time",@"FaceTime",@"iClod",@"International" ,@"Location Services",@"Music",@"Network",@"Notes",@"Phone",@"Photos" ,@"VPN",@"Wallpaper",@"Wi-Fi",@"About",@"Accessibility",@"Airplane Mode On"]; } return _kJumpArr;}-(NSArray *)kUrlArr{ if (_kUrlArr==nil) { _kUrlArr=@[@"prefs:root=Brightness" ,@"prefs:root=General&path=Bluetooth" ,@"prefs:root=General&path=DATE_AND_TIME",@"prefs:root=FACETIME" ,@"prefs:root=CASTLE",@"prefs:root=General&path=INTERNATIONAL" ,@"prefs:root=LOCATION_SERVICES",@"prefs:root=Music" ,@"prefs:root=General&path=Network",@"prefs:root=NOTES" ,@"prefs:root=Phone",@"prefs:root=Photos",@"prefs:root=General&path=Network/VPN" ,@"prefs:root=Wallpaper",@"prefs:root=WIFI",@"prefs:root=General&path=About" ,@"prefs:root=General&path=ACCESSIBILITY" ,@"prefs:root=AIRPLANE_MODE"]; } return _kUrlArr;}@end
#import "SecondViewController.h"#import <Masonry.h>@interface SecondViewController ()@property(nonatomic,retain) NSArray *kJumpArr;@property(nonatomic,retain) NSArray *kUrlArr;@end@implementation SecondViewController- (void)viewDidLoad { [super viewDidLoad]; [self uiConfig];}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning];}-(void)uiConfig{ self.view.backgroundColor=[UIColor whiteColor]; self.edgesForExtendedLayout=UIRectEdgeNone; CGFloat topSpace=(self.view.frame.size.height-[self.kJumpArr count]*10-([self.kJumpArr count]-1)*15)/2; for (int i=0;i<[self.kJumpArr count]; i++) { UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom]; [btn setTitle:self.kJumpArr[i] forState:UIControlStateNormal]; [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; [btn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted]; btn.tag=10+i; [btn addTarget:self action:@selector(butttonAction:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; [btn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.view.mas_top).offset(topSpace+i*25); make.height.mas_equalTo(10); make.centerX.equalTo(self.view.mas_centerX); make.width.mas_equalTo(300); }]; }}-(void)butttonAction:(UIButton *)button{ NSInteger num=button.tag-10; NSURL *url=[NSURL URLWithString:self.kUrlArr[num]]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; }}-(NSArray *)kJumpArr{ if (_kJumpArr==nil) { _kJumpArr=@[ @"AutoLock",@"General",@"Keyboard",@"iCloud Storage & Backup",@"Music Equalizer",@"Music Volume Limit",@"Nike+iPod",@"Notification",@"Profile" ,@"Reset",@"Safari",@"Siri",@"Sounds",@"Software Update",@"Store" ,@"Twitter",@"Usage"]; } return _kJumpArr;}-(NSArray *)kUrlArr{ if (_kUrlArr==nil) { _kUrlArr=@[@"prefs:root=General&path=AUTOLOCK" ,@"prefs:root=General",@"prefs:root=General&path=Keyboard" ,@"prefs:root=CASTLE&path=STORAGE_AND_BACKUP",@"prefs:root=Music*path=EQ" ,@"prefs:root=Music&path=VolumeLimit",@"prefs:root=NIKE_PLUS_IPOD" ,@"prefs:root=NOTIFICATIONS_ID" ,@"prefs:root=General&path=ManagedConfigurationList",@"prefs:root=General&path=Reset" ,@"prefs:root=Safari",@"prefs:root=General&path=Assisitant" ,@"prefs:root=Sounds",@"prefs:root=General&path=SOFTWARE_UPDATE_LINK" ,@"prefs:root=STORE",@"prefs:root=TWITTER" ,@"prefs:root=General&path=USAGE"]; } return _kUrlArr;}@end
0 0
- 应用跳转到系统设置里的各种设置界面
- 如何跳到系统设置里的各种设置界面
- 如何跳到系统设置里的各种设置界面
- 如何跳到系统设置里的各种设置界面
- 如何跳到系统设置里的各种设置界面
- 如何跳到系统设置里的各种设置界面
- iOS中APP跳转到系统的各种设置界面
- 应用内跳转到系统设置界面
- 应用跳转到系统设置的WiFi界面
- iOS应用 跳转到系统的设置界面
- App应用里应该自动跳转到系统设置界面吗?
- App应用里应该自动跳转到系统设置界面吗?
- iOS 跳转到系统的设置界面
- iOS 跳转到系统的设置界面
- iOS 跳转到系统的设置界面
- iOS 跳转到系统的设置界面
- iOS 跳转到系统的设置界面
- iOS 跳转到系统的设置界面
- 【2015广东工业大学新生赛A】【排序 二进制数位思想】GG和女神 数字按照数值排序后取了多少个数
- Opencv 任意区域选中
- http 头信息详解
- 亲情无价
- 【2015广东工业大学新生赛B】【数论 素因子拆分】小刀带你们玩游戏 lcm(A,B)==C下B的个数
- 应用跳转到系统设置里的各种设置界面
- 【2015广东工业大学新生赛C】【贪心 快速幂】长度为n的最小47倍数
- 【详解】Python下载图片
- javascript day01天,基础整理
- 租房注意事项
- 【2015广东工业大学新生赛D】【数论-欧拉函数】求互质对数 1~n中互质数对数
- RandomAccessFile
- java字符串截取
- 《iOS Human Interface Guidelines》——From Concept to Product