專案步驟:
1. UI TableView 元件製作:拖曳 UITableView Control 至 Storyboard
2. 設定 Table View 的 Attribute : prototype cell = 1 (原來的值是 0)
3. 設定 Table View 的 Cell Style : Basic
4. 設定 cell 的識別名稱 Identifier = cell
5. 試 Run
6. 在 code 中加入 Table View 需遵循的 protocol :
class ViewController : UIViewController, UITableViewDataSource,
UITableViewDelegate
7. Data 準備 :提供 data
8. Protocol 實作 : delegate
9. 建立 UI 與 Code 的 connect : 將 TableView 此 control 拉至 Outline 的 ViewController
10. 試 Run
11. 刪除 Status Bar
12. 試 Run
開啟新專案:
1. UI TableView 元件製作:拖曳 UITableView Control 至 Storyboard
2. 設定 Table View 的 Attribute : prototype cell = 1 (原來的值是 0)
3. 設定 Table View 的 Cell Style : Basic
4. 設定 cell 的識別名稱 Identifier = cell
5. 試 Run
6. 在 code 中加入 Table View 需遵循的 protocol :
class ViewController : UIViewController, UITableViewDataSource,
UITableViewDelegate
7. Data 準備 :提供 data
8. Protocol 實作 : delegate
9. 建立 UI 與 Code 的 connect : 將 TableView 此元件拉至 Outline 的 ViewController
顯示 connect to data source 與 data delegate
10. 試 Run
11. 刪除 Status Bar
12. 試 Run
後記:
這程式使用 UITableView 元件,增加 protocol 協定的概念。當遵循此 protocol 時,其方法需實作。
參考:
1. UITableView, https://developer.apple.com/library/prerelease/ios/samplecode/TableMultiSelect/Introduction/Intro.html
2. UITableView Class Reference, https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableView_Class/
3. UITableViewDataSource Class Reference, https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableViewDataSource_Protocol/index.html#//apple_ref/occ/intf/UITableViewDataSource
4. UITableViewDelegate Reference Class, https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/index.html#//apple_ref/occ/intf/UITableViewDelegate
“Those who are in love with practice without knowledge are like the sailor who gets into a ship without rudder or compass and who never can be certain [where] he is going. Practice must always be founded on sound theory.” by Leonardo da Vinci
2015年9月9日 星期三
第 2 個程式:SimpleTableView
訂閱:
張貼留言 (Atom)














沒有留言:
張貼留言