如何使用 uitableviewcontroller
来源:互联网 发布:windows正版验证补丁 编辑:程序博客网 时间:2024/06/02 04:19
转载自:http://hi.baidu.com/taoofsong/item/fef493df3edda6dc251f40dd
如何使用 uitableviewcontroller?? 嘿嘿,简单的呢
我以前使用tableview视图,也是在uiview里面 加上一个表视图控件,偶然发现还有个 tableviewcontrollr。
如果你只需要使用一个表示图,那就使用tableviewcontroller把! 他很方便,很简洁!
使用方法很简单,shouxia首先在头文件加上2个 委托
@interface TestApp01AppDelegate : NSObject <UIApplicationDelegate,UITableViewDelegate,UITableViewDataSource> {
UINavigationController *nav ;
NSArray *array;
}
其次就是
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
array = [[NSArrayalloc] initWithObjects:@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1", nil];
UITableViewController *table = [[UITableViewControlleralloc] initWithStyle:UITableViewStylePlain];
table.tableView.dataSource =self;
table.tableView.delegate = self;
UIToolbar *toolbar = [[UIToolbaralloc] initWithFrame:CGRectMake(0, 0,320, 30)];
table.tableView.tableHeaderView = toolbar;
[self.windowsetRootViewController:table];
[self.windowmakeKeyAndVisible];
returnYES;
}
然后给你 的cellfuy赋予内容
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arraycount];
}
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
return1;
}
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
staticNSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier] autorelease];
}
NSString *string = [arrayobjectAtIndex:indexPath.row];
cell.textLabel.text = string;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
[cell.textLabelsetFont:[UIFontfontWithName:@"Georgia"size:27]];
[cell.textLabelsetTextColor:[UIColorblueColor]];
return cell;
}
ok了
table.tableView.dataSource =self;
table.tableView.delegate = self;
注意这里
- 如何使用 uitableviewcontroller
- UITableViewController使用
- uitableviewcontroller使用
- IOS 开发使用UIStoryBoard时如何隐藏UITableViewController中的Section
- 使用UITableViewController注意事项
- UITableViewController使用详解
- UITableViewController
- UITableViewController
- UITableViewController
- UITableViewController
- UItableViewController
- UITableViewController
- UITableViewController
- UITableViewController
- UITableViewController
- UITableViewController
- UITableViewController
- iOS之UITableViewController的使用
- AppWidget开发实例讲解(一)
- 对redis数据持久化的一些想法
- 谁说Vim不是IDE?(一)
- WinForm多线程学习文档
- HDU OJ 3308 LCIS 【线段树之区间合并】
- 如何使用 uitableviewcontroller
- body-content取值的意义
- CSS的position与float的问题
- 家电辐射排行
- 金融(Finance) 精萃
- windows下DOS命令总结
- matlab set函数
- SAP PP 中关于计划订单和生产订单的日期计算
- php中urlencode和rawurlencode的区别,以及对utf的处理