2015年5月8日 星期五

練習UITbaleView

其實有點複雜...因為程式碼很長!哈!

三個關鍵要素:
版面配置
放啥進去
回應操作(如何回應使用者的操作):需要指定委派 delegate

觀念:
(摘自Beginning Ios 5 Development Exploring The Ios Sdk Beginning Ios 5 Development

清單的每個項目都是一列(row)
iOS表格只能有一個欄(iOS5,現在不知道怎樣,但可以在一欄中排列圖文等。)

每一個可見的列都是UITableViewCell類別的一個實例。

群組式grouped與無格式plain(以及帶有索引的)

注意:群組式表格不應該建立索引

建立一個資料陣列傳給表格!


摘自:The-iOS-Developers-Cookbook-Programmers
p569

Data Source Methods
To display a table, every table data source must implement three core methods.These methods define how the table is structured and provide contents for the table:


numberOfSectionsInTableView—Tables can display their data in sections or as a single list. For simple tables, return 1.This indicates that the entire table should be presented as one single list. For sectioned lists, return a value of 2 or higher.


tableView:numberOfRowsInSection:—This method returns the number of rows for each section.When working with simple lists, return the number of rows for the entire table here. For more complex lists, you’ll want to provide a way to report back per section.As with all counting in iOS,section ordering starts with 0 as the first section.


tableView:cellForRowAtIndexPath:—This method returns a cell to the call- ing table. Use the index path’s row and section properties to determine which cell to provide and make sure to take advantage of reusable cells where possible to min- imize memory overhead. 


跳題的問題:以前有static table,可以直接設定簡易表格,還存在嗎?

程式碼等待補上:


沒有留言:

張貼留言

歡迎網友的交流與分享,謝謝。