iOS5开发:从程序里直接跳转到设置项的实现和代码分享(类似于金山电池医生功能,iOS5有效)
转自:
http://blog.csdn.net/ibright/article/details/7276810
参考链接:
http://hi.baidu.com/yanh105/blog/item/ddd85cf9fff419949f51465c.html
http://iphone.tgbus.com/tutorial/use/201111/20111118151520.shtml
http://iphone.tgbus.com/zt/homeicon/
代码如下:
#import <UIKit/UIKit.h>
@interface OMGViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{
UITableView *_brightTableView;
NSMutableArray *_brightData;
}
@end
#import "OMGViewController.h"
@implementation OMGViewController
- (void)loadData
{
_brightData = [[NSMutableArray alloc] init];
[_brightData addObject:@"About — prefs:root=General&path=About"];
[_brightData addObject:@"Accessibility — prefs:root=General&path=ACCESSIBILITY"];
[_brightData addObject:@"Airplane Mode On — prefs:root=AIRPLANE_MODE"];
[_brightData addObject:@"Auto-Lock — prefs:root=General&path=AUTOLOCK"];
[_brightData addObject:@"Brightness — prefs:root=Brightness"];
[_brightData addObject:@"Bluetooth — prefs:root=General&path=Bluetooth"];
[_brightData addObject:@"Date & Time — prefs:root=General&path=DATE_AND_TIME"];
[_brightData addObject:@"FaceTime — prefs:root=FACETIME"];
[_brightData addObject:@"General — prefs:root=General"];
[_brightData addObject:@"Keyboard — prefs:root=General&path=Keyboard"];
[_brightData addObject:@"iCloud — prefs:root=CASTLE"];
[_brightData addObject:@"iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP"];
[_brightData addObject:@"International — prefs:root=General&path=INTERNATIONAL"];
[_brightData addObject:@"Location Services — prefs:root=LOCATION_SERVICES"];
[_brightData addObject:@"Music — prefs:root=MUSIC"];
[_brightData addObject:@"Music Equalizer — prefs:root=MUSIC&path=EQ"];
[_brightData addObject:@"Music Volume Limit — prefs:root=MUSIC&path=VolumeLimit"];
[_brightData addObject:@"Network — prefs:root=General&path=Network"];
[_brightData addObject:@"Nike + iPod — prefs:root=NIKE_PLUS_IPOD"];
[_brightData addObject:@"Notes — prefs:root=NOTES"];
[_brightData addObject:@"Notification — prefs:root=NOTIFICATIONS_ID"];
[_brightData addObject:@"Phone — prefs:root=Phone"];
[_brightData addObject:@"Photos — prefs:root=Photos"];
[_brightData addObject:@"Profile — prefs:root=General&path=ManagedConfigurationList"];
[_brightData addObject:@"Reset — prefs:root=General&path=Reset"];
[_brightData addObject:@"Safari — prefs:root=Safari"];
[_brightData addObject:@"Siri — prefs:root=General&path=Assistant"];
[_brightData addObject:@"Sounds — prefs:root=Sounds"];
[_brightData addObject:@"Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK"];
[_brightData addObject:@"Store — prefs:root=STORE"];
[_brightData addObject:@"Twitter — prefs:root=TWITTER"];
[_brightData addObject:@"Usage — prefs:root=General&path=USAGE"];
[_brightData addObject:@"VPN — prefs:root=General&path=Network/VPN"];
[_brightData addObject:@"Wallpaper — prefs:root=Wallpaper"];
[_brightData addObject:@"Wi-Fi — prefs:root=WIFI"];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadData];
// Do any additional setup after loading the view, typically from a nib.
_brightTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
_brightTableView.delegate = self;
_brightTableView.dataSource = self;
[self.view addSubview:_brightTableView];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [_brightData count];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 44.0f;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"BookmarkCell";
UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
NSString *string = [_brightData objectAtIndex:indexPath.row];
NSArray *array = [string componentsSeparatedByString:@" — "];
cell.textLabel.text = [array objectAtIndex:0];
cell.detailTextLabel.text = [array objectAtIndex:1];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *string = [_brightData objectAtIndex:indexPath.row];
NSArray *array = [string componentsSeparatedByString:@" — "];
UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectZero];
//web.hidden = YES;
[self.view addSubview:web];
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[array objectAtIndex:1]]];
[web loadRequest:req];
[req release];
[web release];
/*
NSURL*url=[NSURL URLWithString:[array objectAtIndex:1]];
[[UIApplication sharedApplication] openURL:url];
*/
}
@end
iOS5开发:从程序里直接跳转到设置项的实现和代码分享(类似于金山电池医生功能,iOS5有效)相关推荐
- php程序里如何实现图片翻页,php图片上传代码一例-php 生成翻页链接(页码)列表的...-带多种分页方式的php分页类_169IT.COM...
Class PAGE { //类开始 /******************************************************** * $total 记录总数 * $ ...
- Java开发桌面程序学习(七)——ImageView设置图片以及jar包读取fxml文件
ImageView设置图片 JavaFx的ImageView,设置图片不能直接通过属性设置,只能通过代码来设置 ImageView设置图片 首先,我们让fxml对应的那个controller的java ...
- 自动跳转手机版和电脑版html代码,分享两个手机访问pc网站自动跳转手机端网站代码...
4G降临,移动网站已经一发不可收拾,pc端和移动端官网并存.如何让别人访问你的pc端的官网直接跳转到移动端的网站呢?各位看官,小二上代码!来了! 常用的访问pc自动跳转到移动页面的代码 (functi ...
- Android 类似《金山电池医生》里的那些电量时间是如何计算的?具体看图
跪求大神赐教!!!(参与研讨就酌情给分)
- 小程序高级电商前端第1周走进Web全栈工程师一----小程序注册、开发工具推荐、《风袖》首页布局详尽分析、Webstorm开发小程序必配配置、mock数据...
接下来开启一门全新的课程的学习,其实这是去年6月份所记录的,只是木有公开,然后到目前为止已经间隔了快1年没管了,基本上是已经快放弃的节奏,但是呢它又是我一直特别想学习的,所以决定公开,鞭策自己得继续前 ...
- 识别喜欢开发的程序员
识别一个程序员是否喜欢开发,在你遇到下面的情境时特别重要: 你要招募小伙伴 你要选择结对的开发人员 你想变得更好更强大(与优秀的人在一起事半功倍) 研发新产品,你要从公司内部抽调人手组建团队 你想判断 ...
- 开发小程序的正确方式
工欲善其事必先利其器,在开发小程序之前,不妨让我们先来了解清楚,什么是正确的方式与工具. 如同我们在<小程序的昨日与今天>一文中所说,小程序的开发并不需要配置任何开发环境,只需要安装官方的 ...
- 开发 web 程序服务 之 源码分析
文章目录 开发 web 程序服务 之 源码分析 前言 http 包源码 路由部分 监听和服务部分 mux 库源码 源码分析 创建路由 路由匹配 总结 开发 web 程序服务 之 源码分析 前言 本文的 ...
- android开发UI界面布局教学,android UI学习 -- 设置界面的布局(包括style的使用,selector的使用,Checkbox自定义样式,菜单项的样式)...
最终实现效果如下图: 具体来说就是实现了checkbox自定义选中和为选择样式,菜单项根据不同位置设置不同背景. 先上整体布局文件代码: xmlns:tools="http://schema ...
最新文章
- 利用System.Uri转URL为绝对地址
- css样式脱离标准文档流
- Cocos2d 之FlyBird开发---GameData类
- Knative 实战:基于 Kafka 实现消息推送
- jQuery Mobile动态刷新页面样式
- LeetCode——Word Break
- Spyder里面好像不能用汉字
- Best Practices for AWS Security Using CloudCheckr
- 删除oracle补丁包,最新Oracle关键补丁:更新包括248个修复
- DSP及海思嵌入式板实现gb28181
- POJ-3468-A Simple Problem with integers
- 台电tbook10s官方固件_台电TbooK 10 S (E5N5)-双系统平板电脑固件
- 大数据+人工智能时代,电子招投标更符合未来趋势
- Xiaojie雷达之路---车载雷达信号处理流程
- 灰度持续加仓,FIL即将大涨
- 回忆某图,如滔滔江水
- 大天使之剑h5服务器临时维护,《大天使之剑H5》2月28日维护更新公告
- 经典的期货量化交易策略大全(含源代码)
- stm32直流电机控制—PID算法篇
- 一文搞懂什么是图神经网络GNN【入门教程】