| Table View Styles and Accessory View |
| Table View StylePlain StyleGroup Style其實plain通常用于顯示同類的一連貫數據,而Group更適合于用來顯示不同類型的數據。其中plain能有indicator,而group不能有。 |
Standard Style for Table View CellsUITableView提供四種默認的Cell樣式:UITableViewCellStyleDefaultUITableViewCellStyleSubtitle UITableViewCellStyleValue1UITableViewCellStyleValue2UITableViewCellStyleDefault:![]() ![]() UITableViewCellStyleSubtitle :![]() UITableViewCellStyleValue1:![]() UITableViewCellStyleValue2:![]() ![]() |
Accessory ViewsUITableCell提供三種默認的附件:![]() ![]() |
| Overview of the Table View API |
| Table View |
| Table View ControllerUITableViewController自動集成了一個UITableView,所以若需求是一個連續的Table界面,可以直接使用它。 |
| Data Source and Delegate |
| Extension to the NSIndexPath ClassUITableView通過category的方式擴展了NSIndePath,使其具備row & section屬性來更好地定位TableView的item |
| Table View Cells |
| Navigating a Data Hierarchy with Table ViewsUITableView一個最為通用的用法就是用來導航瀏覽一個具有層級關系的數據 |
| Hierarchical Data Models and Table View |
| View Controller and Navigation-Based Apps |
| Design pattern for Navigation-Based Apps |
| Creating and Configuring a Table View |
Basic of Table View Creation![]() ![]() |
A Closer Look at Table View CellsUITableViewCell設計如下:![]() Cell有通用模式和編輯模式:通用模式只有content、accessory View兩個部分,acessory通常僅用于顯示指示圖標,如checkmark。編輯模式有editing、content、recording三部分,其中editing部分通常用于批量處理,而reordering 部分現在除了可用于重新排序呢,還可以用于刪除曹組。UITabelViewCell提供四種默認的Cell樣子,若以下四種不能滿足,則需要自定義。![]() ![]() |
| Managing Selections |
Inserting and Deleting Rows and Sections當Cell處于編輯模式,我們可以實現row與section的inset、delete、reorder,批處理四種效果。以下為client觸發編輯模式并進行刪除或者插入操作的時序圖(時序圖的執行順序是從上而下):![]() setEditing:animated = 讓table view 進去或者取消編輯模式tableView:canEditRowAt = 確認指定的行列是否可以進入編輯模式tableView:editingStyleForRowAtIndexPath = 制定某行進行編輯模式,這時候editing control已經顯示在界面上了tableView:commitEditingStyle:forRowAtIndexPath ,雖然這是一個可選方法,但在需要實現刪除或者插入的操作時必須實現,并且得根據情況調用以下方法:deleteRowsAtIndexPaths:withRowAnimation:insertRowsAtIndexPaths:withRowAnimation:調用完以上方法還需要同時更新數據模型。 |
Batch Insertion ,Deletion,and Reloading of rows and section![]() ![]() |
Managing the reordering of rows![]() 當table view收到setEditing:animation: 消息就會發送相同的消息給相應的cell,然后就會觸發以下流程:table view發送tableView:canMoveRowAtIndexPath給DataSource,執行特定的cell能夠顯示reordering control。每當一個拖動cell行為完成,tableView:targetIndexPathForMoveFromRowAtIndexPath:toPRoposedIndexPath:這個delegate方法用于判讀這個動作是否效果若上面的方法判定有效,則調用dataSource方法,tableView:moveRowAtIndexPath:toIndexPath: 更新model。 |
新聞熱點
疑難解答