
#import "RootVIEwController.h"
@implementation RootVIEwController
@synthesize contactinformationVIEwController;
//定义表格中的数据集合
NSMutableArray *listofContacts;
//当窗口加载完成初始化数据集合的内容
- (voID)vIEwDIDLoad {
[super vIEwDIDLoad];
listofContacts = [[NSMutableArray @H_301_52@alloc] @H_301_52@init];
[listofContacts @H_301_52@addobject:@"张三"];
[listofContacts @H_301_52@addobject:@"李四"];
self.navigationItem.Title = @"联系人";
[super vIEwDIDLoad];
}
//只有一组列表显示如果显示,返回值为组数
- (NSInteger)numberOfSectionsIntableVIEw:(UItableVIEw *)tableVIEw {
return 1;
}
//关键方法,返回当前列表一共有多少行
- (NSInteger)tableVIEw:(UItableVIEw *)tableVIEw numberOfRowsInSection:(NSInteger)section {
return [listofContacts @H_301_52@count];
}
//定义表格中的每一行显示的内容,在这里假如nslog 就可以知道运行原理了
- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static Nsstring *CellIDentifIEr = @"Cell";
UItableVIEwCell *cell = [tableVIEw @H_301_52@ dequeueReusableCellWithIDentifIEr:CellIDentifIEr]; //获取内存中的条目,如果获取失败则创建该条目
if (cell == nil) {
cell = [[[UItableVIEwCell alloc] initWithStyle:UItableVIEwCellStyleDefault reuseIDentifIEr:CellIDentifIEr] autorelease];
}
cell.textLabel.Font = [UIFont @H_301_52@systemFontOfSize:17];
Nsstring *cellValue = [listofContacts @H_301_52@objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
//实现选中某一行的事件处理
- (voID)tableVIEw:(UItableVIEw *)tableVIEw dIDSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath @H_301_52@ row];
Nsstring *contactname = [listofContacts @H_301_52@objectAtIndex:row];
if (self.contactinformationVIEwController == nil) { //创建一共d出窗口
ContactinformationVIEwController *c = [[ContactinformationVIEwController @H_301_52@alloc]
@H_301_52@initWithNibname:@"ContactinformationVIEw"
@H_301_52@bundle:[NSBundle @H_301_52@ mainBundle]];
self.contactinformationVIEwController = c;
[c @H_301_52@release];
}
[self.contactinformationVIEwController initWithContactname:contactname];
//d出窗口
[self.navigationController @H_301_52@pushVIEwController:self.contactinformationVIEwController
@H_301_52@animated:YES];
}
- (voID)dealloc {
[listofContacts @H_301_52@release];
[super @H_301_52@dealloc];
}
@end
总结以上是内存溢出为你收集整理的ipad开发对表格视图的基本实现全部内容,希望文章能够帮你解决ipad开发对表格视图的基本实现所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)