最終效果
直接上**
首先使uiviewcontroller
實現協議
uitableviewdatasource
,uitableviewdelegate
建立兩個屬性
uitableview *personaltableview;
nsarray *datasource;
[objc]view plain
copy
@inte***ce
userinfoviewcontroller ()
初始化[objc]view plain
copy
personaltableview=[[uitableview
alloc
]initwithframe:cgrectmake(0,
44+2
0, screen_width, screen_height-20
-44-
49)style
:uitableviewstylegrouped];
[self
.view
addsubview
:personaltableview];
personaltableview.delegate
=self
; personaltableview.datasource
=self
; personaltableview.bounces=no
; personaltableview.showsverticalscrollindicator
= no
;//不顯示右側滑塊
personaltableview.separatorstyle
=uitableviewcellseparatorstylesingleline;
//分割線
datasource=@[@"我的分享"
,@"密碼管理"
,@"使用者協議"
,@"關於"
];
實現一下幾個**
[objc]view plain
copy
#pragma mark tableviewdelegate
-(nsinteger)numberofsectionsintableview:(uitableview
*)tableview
//設定每個分組下tableview的行數
-(nsinteger)tableview:(uitableview
*)tableview
numberofrowsinsection
:(nsinteger)section
else
if(section==
1) else
} //每個分組上邊預留的空白高度
-(cgfloat)tableview:(uitableview
*)tableview
heightforheaderinsection
:(nsinteger)section
//每個分組下邊預留的空白高度
-(cgfloat)tableview:(uitableview
*)tableview
heightforfooterinsection
:(nsinteger)section
return20
; }
//每乙個分組下對應的tableview 高度
-(cgfloat)tableview:(uitableview
*)tableview
heightforrowatindexpath
:(nsindexpath
*)indexpath
return40
; }
//設定每行對應的cell(展示的內容)
-(uitableviewcell
*)tableview:(
uitableview
*)tableview
cellforrowatindexpath
:(nsindexpath
*)indexpath
if(indexpath
.section==0
) else
if(indexpath
.section==1
) else
return
cell;
}
到此為止基本實現了整個介面
如果有問題可加qq討論
蘋果開發群 :414319235 歡迎加入
iOS 中tableview的使用
section總數 nsarray sectionindextitlesfortab leview uitableview tableview section titles 每個section顯示的標題 nsstring tableview uitableview tableview titlefo...
iOS使用CollectionView實現瀑布流
將螢幕等分成三列 然後將載入到每一列中,在加入到列之前,首先判斷那一列的高度最低,然後把加到高度最低的那列中。使用uicollectionview,採用自定義布局的方式,設定cell的排列規則 完成瀑布流。自定義布局中,指定滾動方向,預設列數,行間距,列間距,以及指定cell的大小itemsize ...
iOS效能優化 TableView
下面介紹一些我們可以自己設定的新能優化 1 盡量不透明的檢視 不透明檢視可以極大提高渲染的速度.因此如果可以,將 cell 及其子檢視的 opaque 屬性設定為 yes 預設值 cell 的 backgroundcolor 的 apha 值應為1 不要使用 clearcolor 影象的 apha ...