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

    参考链接:

    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

  • 相关阅读:
    Convert Datetime to String in Sql Server
    [转]C# 多线程
    [转]C#的内存管理:堆栈、托管堆与指针
    [转]js操作select相关方法(收集)
    [转]javaScript中URL编码转换,escape() encodeURI() encodeURIComponent
    Compile android NDK without Eclipse
    BlockingQueue and BlockingDeque
    Android Notebook
    java.String.format &Formatter
    Install Git for Eclipse
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/2458442.html
Copyright © 2011-2022 走看看