IOS-UITableView入門(1)

來源:互聯網
上載者:User

UITableView 類比android的ListView,指的是擁有相同視圖不同資料的列表.例如的連絡人清單

1.UITableViewDelegate,UITableViewDataSource分別為UITableView的資料與行為的代理.

也就是UITableView本身什麼都不幹,他的資料載入由來實現,而行為由來實現.

2.UITableView的列表分為兩種形式,一種是plain(單列表)形式,一種是Group(列表組)形式.

Group Plain

<喎?http://www.bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+tbHOqrWl1+nB0LHtyrEst7W72DEgtbHOqrbg1+nB0LHtyrEst7W72D4xtcTK/dfWPC9wPgo8cD48L3A+CjxwcmUgY2xhc3M9"brush:java;">- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;

根據section為返回的組數判斷.返回每組的列數


-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section;

這裡有幾個術語需要解釋

Section:組數或者列數

indexPath:indexPath.row表示某組的列數

indexPath.section 表示組數

3.如何顯示列表呢?做過Android-ListView的都知道,該列表的adapter裡面實現了視圖緩衝,某個item只在第一次建立,以後的工作只是重複賦值.在ios中,返回的每個item為UITableViewCell及其子類

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;



所以,通過組數 列數 每列的樣式 可以初步顯示整個列表的摸樣.


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.