因祸得福--学会了怎样创建并使用一个公用的模块类
2014-02-12 11:12
453 查看
通过前面的学习,知道怎样通过storyboard实现几个模块之间的导航。后来衍生到工作中,例如要实现一个这样的程序:
有一个多人的人员列表tableview,点击某个人员就会进入该人员的信息列表。
如果需要stroyboard实现,则需要创建很多的画板,画无数个segue,而且如果人员信息来自于数据库,则是动态的,所以需要一个公用的模块类来实现。
以上是背景,其实这是一种我原来一直想找的方法,也是受某专家的指点(他提到了这个方法,我不好意思再继续问详细的,想自己解决)
在网上找到这位http://www.cnblogs.com/minglz/p/仁兄的博客,里面第十四-十六章就解决了我的问题。
顺便说一下,后面准备好好看下他推荐的这本英文原版书《Beginning iOS 6 Development Exploring the iOS SDK》
实现方法就按他说的做,但是我自己将之升级为如此:
实现方法,就是在BIDFirstLevelController.m中重复再加一段
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"First Level";
NSMutableArray *array = [[NSMutableArray alloc] init];
// Disclosure Button
BIDDisclosureButtonController *disclosureButtonController1 = [[BIDDisclosureButtonController alloc] initWithStyle:UITableViewStylePlain];
disclosureButtonController1.title = @"Disclosure Buttons 1";
disclosureButtonController1.rowImage = [UIImage imageNamed:@"disclosureButtonControllerIcon.png"];
[array addObject:disclosureButtonController1];
BIDDisclosureButtonController *disclosureButtonController2 = [[BIDDisclosureButtonController alloc] initWithStyle:UITableViewStylePlain];
disclosureButtonController2.title = @"Disclosure Buttons 2";
disclosureButtonController2.rowImage = [UIImage imageNamed:@"disclosureButtonControllerIcon.png"];
[array addObject:disclosureButtonController2];
self.controllers = array;
}
通过上面的就将 BIDDisclosureButtonController对象添加到了controllers数组中,(如果是数据库中的成员,就循环添加),后面显示在tableview列表
中是通过在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}实现(该函数会通过得到的行数循环),这些方法都是继承于UITableViewController基类。
有一个多人的人员列表tableview,点击某个人员就会进入该人员的信息列表。
如果需要stroyboard实现,则需要创建很多的画板,画无数个segue,而且如果人员信息来自于数据库,则是动态的,所以需要一个公用的模块类来实现。
以上是背景,其实这是一种我原来一直想找的方法,也是受某专家的指点(他提到了这个方法,我不好意思再继续问详细的,想自己解决)
在网上找到这位http://www.cnblogs.com/minglz/p/仁兄的博客,里面第十四-十六章就解决了我的问题。
顺便说一下,后面准备好好看下他推荐的这本英文原版书《Beginning iOS 6 Development Exploring the iOS SDK》
实现方法就按他说的做,但是我自己将之升级为如此:
实现方法,就是在BIDFirstLevelController.m中重复再加一段
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"First Level";
NSMutableArray *array = [[NSMutableArray alloc] init];
// Disclosure Button
BIDDisclosureButtonController *disclosureButtonController1 = [[BIDDisclosureButtonController alloc] initWithStyle:UITableViewStylePlain];
disclosureButtonController1.title = @"Disclosure Buttons 1";
disclosureButtonController1.rowImage = [UIImage imageNamed:@"disclosureButtonControllerIcon.png"];
[array addObject:disclosureButtonController1];
BIDDisclosureButtonController *disclosureButtonController2 = [[BIDDisclosureButtonController alloc] initWithStyle:UITableViewStylePlain];
disclosureButtonController2.title = @"Disclosure Buttons 2";
disclosureButtonController2.rowImage = [UIImage imageNamed:@"disclosureButtonControllerIcon.png"];
[array addObject:disclosureButtonController2];
self.controllers = array;
}
通过上面的就将 BIDDisclosureButtonController对象添加到了controllers数组中,(如果是数据库中的成员,就循环添加),后面显示在tableview列表
中是通过在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}实现(该函数会通过得到的行数循环),这些方法都是继承于UITableViewController基类。
相关文章推荐
- 如何在Node.js中使用npm创建和发布一个模块
- 一个使用泛型堆栈模块创建的两个容纳不同类型数据的实例
- 使用NodeJs的express模块创建一个服务器
- 怎样使用MFC创建一个窗口类
- 如何使用IntelliJ Idea创建一个分模块Maven+Web项目
- 怎样使用android创建一个手机信息页面
- 第1章-安装Node.js及相关要点-1.7.使用Node.js的HTTP模块来创建一个简单服务器
- 怎样不使用Useradd在linux下创建一个新的用户
- 一个模块使用另一个模块导出的符号,该模块怎样编译?很经典!
- 怎样使用纯CSS3创建一个简单的五角星图形
- 使用 ADD-ON SDK 开发 基于 Html JQuery 和 CSS 的 firefox 插件入门教程1: 创建一个简单的 Add-on
- CryENGINE3初探Entities (一)----使用Lua创建一个自定义Entity并为其添加节点
- 如何使用Core Text创建一个简单的杂志图书App
- 怎样在IDEA中使用JUnit4和JUnitGenerator V2.0自动生成测试模块
- 使用PHP创建一个REST API(Create a REST API with PHP)
- 使用Spring来创建一个简单的工作流引擎
- 基于maven使用IDEA创建多模块项目
- spring cloud教程之使用spring boot创建一个应用
- 使用PHP创建一个REST API(Create a REST API with PHP)节选5
- 三分钟让你学会如何使用 apache-common-pool2 创建自己的资源池