UITableView使用详解
uitableview
tableview的使用
it
UI攻略)viewDidLoad
viewDidLoad
//
@""@""@""@""@""
*array2_=,;
*array3_=;
.=:array1_, :array2_, :array3_;
alloc initWithFrameCGRectMake styleUITableViewStylePlain
=;
=;
//lyttzx.com
=[ ];
//Header
=;
//footer
=;
//
=;
//cellUITableViewCellSeparatorStyleSingleLine
setSeparatorStyleUITableViewCellSeparatorStyleSingleLine
//cell
setSeparatorColor redColor
//tableView
=;
. :myTableView_];
//row or section
scrollToRowAtIndexPath indexPathForRowinSection
atScrollPositionUITableViewScrollPositionBottom animated
(Section)1
)numberOfSectionsInTableView:( *)tableView {
[[. ] ];
section sectionHeaderHeight
)tableView:( *)tableView heightForHeaderInSection:()section{
;
section sectionFooterHeight
)tableView:( *)tableView heightForFooterInSection:()section{
;
sectionHeader
*)tableView:( *)tableView titleForHeaderInSection:()section{
[[. ] :section];
sectionFooter
*)tableView:( *)tableView titleForFooterInSection:()section{
return nil
sectionHeader
*)tableView:( *)tableView viewForHeaderInSection:()section{
return nil
sectionFooter
*)tableView:( *)tableView viewForFooterInSection:()section{
*p_w_picpathView_=[[ ]:(, ,, )];
=[ :];
[p_w_picpathView_ ];
指定每个分区中有多少行,默认为
)tableView:( *)tableView numberOfRowsInSection:()section{
objectForKey allKeysobjectAtIndexcount
改变行的高度(实现主个代理方法后 设定的高度无效)
)tableView:( *)tableView heightForRowAtIndexPath:( *)indexPath{
;
Cell
*)tableView:( *)tableView cellForRowAtIndexPath:( *)indexPath {
*SimpleTableIdentifier= ;
dequeueReusableCellWithIdentifier
(cell== ) {
alloc initWithStyleUITableViewCellStyleDefault
: SimpleTableIdentifier] ];
setAccessoryTypeUITableViewCellAccessoryDetailDisclosureButton
button
UITableViewCellSelectionStyleBlue
cell
这是设置没选中之前的背景颜色
contentViewbackgroundColor UIColor
p_w_picpathViewp_w_picpathUIImage
p_w_picpathViewhighlightedImageUIImage
.=[[. :[[.]:indexPath.]]:indexPath.];
cell;
行缩进
)tableView:( *)tableView indentationLevelForRowAtIndexPath:( *)indexPath{
row=[indexPath ];
row;
Cell
)tableView:( *)tableView didSelectRowAtIndexPath:(*)indexPath{
deselectRowAtIndexPath animated
//cell
*cell=[tableView :indexPath];
(,cell);
行将显示的时候调用,预加载行
)tableView:( *)tableView willDisplayCell:( *)cell forRowAtIndexPath:( *)indexPath
@"\n cell=%@ \n indexpath=%@"
选中之前执行判断选中的行(阻止选中第一行)
*)tableView:( *)tableView willSelectRowAtIndexPath:( *)indexPath
row=[indexPath ];
(row== )
;
indexPath;
编辑状态,点击删除时调用
)tableView:( *)tableView commitEditingStyle:()editingStyle
*)indexPath
UITableViewCellAccessoryDetailDisclosureButton
)tableView:( *)tableView accessoryButtonTappedForRowWithIndexPath:( *)indexPath{
@"button \n indexpath=%@"
右侧添加一个索引表
*)sectionIndexTitlesForTableView:( *)tableView{
[. ];
celldel
)tableView:( *)tableView canEditRowAtIndexPath:(*)indexPath {