iOS5开发:从程序里直接跳转到设置项的实现和代码分享(类似于金山电池医生功能,iOS5有效)

iOS5开发:从程序里直接跳转到设置项的实现和代码分享(类似于金山电池医生功能,iOS5有效),第1张

参考链接:

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/2091734.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-07-22
下一篇 2022-07-22

发表评论

登录后才能评论

评论列表(0条)

保存