iOS -读取plist文件
来源:互联网 发布:工作日报表软件 编辑:程序博客网 时间:2024/04/28 03:31
// UI-城市列表
//
// Created by jzq_mac on 15/7/30.
// Copyright (c) 2015年 jzq_mac. All rights reserved.
//
#import "ViewController.h"
#import "DetailViewController.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
{
NSArray *allCitys;
UITableView *myTableView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self loadData];
[self creatTableView];
}
#pragma ----------------------获得plist里面的数据----------------------
- (void)loadData{
NSString *path = [[NSBundle mainBundle] pathForResource:@"citys.plist" ofType:nil];
allCitys = [NSArray arrayWithContentsOfFile:path];
NSLog(@"%@", allCitys);
}
#pragma ----------------------初始化TableView----------------------
- (void)creatTableView
{
myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 20, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)-20) style:UITableViewStylePlain];
myTableView.delegate = self;
myTableView.dataSource = self;
[self.view addSubview:myTableView];
}
#pragma ----------------------UITableViewDelegate---------------------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return allCitys.count;
}
#pragma ----------------------UITableViewDataSource---------------------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellID = @"cityCell";//cell的唯一标识符
// TableView查找有没有叫cellID的cell(满一屏的情况)
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
// 如果没有查找到就初始化cell
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
cell.textLabel.text = allCitys[indexPath.row][@"State"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detail = [[DetailViewController alloc]init];
// 模态切换ViewController;用于临时切换到另一个ViewController,把需要显示的ViewController放在最上面 presentedViewController
// 当不再需要刚才放到最上面的ViewController的时候让他消失dismissViewControllerAnimated
detail.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:detail animated:YES completion:nil];
}
- IOS读取.plist文件
- ios读取plist文件
- iOS -读取plist文件
- IOS读取plist资源文件
- IOS读取plist资源文件
- iOS开发:读取plist文件
- IOS读取plist资源文件
- iOS 读取plist文件内容
- IOS读取Plist文件代码
- IOS 读取Json文件、读取plist文件
- iOS 查找plist文件路径读取plist 文件
- iOS开发2:读取plist文件
- iOS开发2:读取plist文件
- iOS 本地plist文件的读取
- iOS 创建.写入.读取plist文件
- iOS plist文件创建于读取
- iOS 创建.写入.读取plist文件
- IOS 读取本地plist类型文件数据
- 2013 蟠桃记
- 【微信分享】王团结:如何用Hadoop/Spark构建七牛数据平台
- hdoj2199Can you solve this equation?
- 多线程访问共享数据(2)
- 生成动态验证图片
- iOS -读取plist文件
- 南阳 oj D的小L 题目366
- 简析HTTPS和HTTP的区别
- 新时代动画电影的互联网宣传
- 2015.07.31
- 快捷键
- 字符串和可变字符串
- MySQL索引背后的数据结构及算法原理
- 在Eclipse中配置NDK自动编译环境builders