UINavigationBar 的用法
来源:互联网 发布:淘宝无法登陆怎么注销 编辑:程序博客网 时间:2024/05/02 10:05
//這邊大同小異 window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; /* Create a main view */ mainView = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; //開始新增一個NavigationBar 並且把它黏上去 navbar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 64.0f)]; [navbar setDelegate: self]; [navbar pushNavigationItem:[[UINavigationItem alloc] initWithTitle: *"OfflineMaps"] animated : true]; [mainView addSubview:navbar]; //開始設計我們的內容 把表單起始化 list = [[NSMutableArray alloc] init];for ( int i = 0; i<4 ; i++)[list addObject:[[NSMutableArray alloc] init]]; // 這邊分成四個區塊 // 0 => Maps// 1 => Routes// 2 => BookMarks// 3 => Info // 這是用來記錄讀進來的檔案的陣列 NSMutableArray *maps = [[NSMutableArray alloc] init]; // Objective-C讀取檔案用的工具 你可以想成 一個檔案總管 NSFileManager *manager = [NSFileManager defaultManager]; // Objective-C讀取檔案夾裡面的檔案是透過 NSString 字串的傳遞 這點還滿有趣的 // 將一個路徑的字串交給 manager 他會把內容物丟到maps這個陣列裡面去 // stringWithFormat:是讓你用一個模版來輸出字串 %[at]用後面 , 的字串取代 // 很抱歉 因為論壇系統會擋掉小老鼠[at] 所以詳細的內容還是看source code好了 [maps addObjectsFromArray:[manager contentsOfDirectoryAtPath:[NSString stringWithFormat:*"%[at]/Media/Maps", NSHomeDirectory()] error:NULL]]; for (NSString *path in maps) { //確認一下這個檔案是不是資料夾 這下面的程式碼是從 Apple Developer的Reference抄來的...BOOL isDir;if ([manager fileExistsAtPath: [NSString stringWithFormat:*"/var/mobile/Media/Maps/%*",path] isDirectory: &isDir ] && isDir){// 如果這個檔案是資料夾 那麼就在辨別 底下是否存在該存在的檔案NSString *folder = [NSString stringWithFormat:*"/var/mobile/Media/Maps/%*",path];if([manager fileExistsAtPath:[NSString stringWithFormat:*"%*/MapTiles.sqlitedb",folder]]){// 好啦 看起來是 那就把這個檔案加入Map那一個區塊[[list objectAtIndex: 0 ] addObject: path]; // 這邊就是Objective-C最特別的地方 用不完的中括號}}else{// 如果不是資料夾 那麼他也許是路徑檔 或者是書籤檔NSLog(*"Checking Bookmark or Routes"); // 這是輸出除錯的資料 不過 我自己是很不會看 log // 底下這段是用來辨別檔案是 Route或是BookMark的 // 也許有更漂亮的寫法 但是 我也是新手 我只追求可行NSDictionary * plist = [NSMutableDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:*"/var/mobile/Media/Maps/%*",path]];NSString *description = [plist description]; //辨別 檔案開頭第六個字元開始的九個字元 形成的字串是NSString *checker = [description substringWithRange: NSMakeRange(6,9)];// detecting bookmark or Routeif ([checker isEqualToString:*"Bookmarks"]){//如果是書籤 就加入書籤這一塊[[list objectAtIndex: 2] addObject: path];}else{ //如果不是書籤 就加入路徑這一塊[[list objectAtIndex: 1] addObject: path];}} } //加上一些細部功能if([[list objectAtIndex:0] count] != 0){[[list objectAtIndex:0] addObject: *"Remove Cache"];}if([[list objectAtIndex:1] count] != 0){[[list objectAtIndex:1] addObject: *"Remove Route"];}if([[list objectAtIndex:2] count] != 0){[[list objectAtIndex:2] addObject: *"Remove Bookmark"];}[[list objectAtIndex:3] addObject: *"Instruction"];table = [[UITableView alloc] initWithFrame:CGRectMake(0.0f,60.0f,320.0f,420.0f) style: 1];// 1 代表 以群組區分的表單 0 代表 平面的表單[mainView addSubview: table];[table setDataSource:self]; [table setDelegate:self]; [table setEditing:NO animated:NO]; table.allowsSelectionDuringEditing = YES; [table setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine]; /* Setup window */ [window makeKeyAndVisible]; [window addSubview: mainView];
- UINavigationBar 的用法
- UI之UINavigationBar的用法
- 导航栏: UINavigationBar用法
- 修改UINavigationBar的背景
- 自定义UINavigationBar的背景
- 自定义UINavigationBar的背景图片
- 自定义UINavigationBar的属性
- 自定义UINavigationBar的背景图片
- 修改UINavigationBar的高度
- UINavigationBar的简单使用
- UINavigationBar的使用小结
- UI:UINavigationBar的使用
- UINavigationBar 的设置
- 设置UINavigationBar的UI
- UINavigationBar的自定义图片
- UINavigationBar的简单实用
- UINavigationBar
- UINavigationBar
- delphi 图表控件使用
- SQL SERVER临时表的使用
- 饿死首阳山
- 应用Moduler方式重构应用
- 昨天又吃多了
- UINavigationBar 的用法
- 数据结构与算法在线资料
- json.js与ExtJS一起使用的问题
- PKU 1001 完成纪录
- Windows下清空IE cache的小脚本
- VC6对话框中,如何实现点击一个按钮,在相应的Edit框里,显示当前时间
- 回传事件错误
- B2C 什么是B2C B2C的意义 B2C发展策略 B2C应用
- ALTER在不同数据库的用法