1. Trang chủ
  2. » Công Nghệ Thông Tin

Pro iOS Table Views pot

336 5,4K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 336
Dung lượng 30,08 MB

Nội dung

[...]... The UITableView and UITableViewController classes The UITableViewDelegate and UITableViewDataSource protocols The UITableView and UITableViewCell view objects All six work together The classes provide the core functionality for the table view, the protocols define various data and interaction methods, and the view objects provide the physical user interface The UITableView Class Hierarchy The UITableView...CHAPTER 1: Table Views from the Ground Up Figure 1–4 The basic anatomy of a table view Table view operations are supported by two UITableView protocols: UITableViewDatasource provides the table view with the data that it needs to construct and configure itself, as well as providing the cells that the table view displays UITableViewDelegate handles most of the methods... does not present a lot of code, it will provide a useful foundation later, when you start to customize table views Along the way, you’ll look at the following: The types and styles of table views The anatomy and dimensions of table views UITableView’s relationship to the UIScrollView superclass Creation of table views in code and with Interface Builder Use of the UITableViewController class to take advantage... STViewController.h interface declaration in Listing 1–4 CHAPTER 1: Table Views from the Ground Up Listing 1–4 Conforming the Class to the UITableDelegate and UITableDataSource Protocols #import @interface STViewController : UIViewController @property (nonatomic, strong) NSMutableArray *tableData; @property (nonatomic) int cellCount; @end This will tell... Understanding Table Views At its simplest, a table view is a list of items that can (often) be scrolled vertically Because this is a common interface design pattern, UIKit provides a powerful suite of classes and protocols to make the creation and management of table views as simple and as effective as possible Table views can range from a very plain list created by using one of the standard styles provided... confusion, I’ll use UITableView when I’m referring to the class, tableView when I’m referring to a specific instance of UITableView, and table view” when I’m talking about table views in general Choosing the Type of Table View Although their visual appearance can be customized to the point where it’s almost difficult to recognize them as instances of the UITableView class at all, table views come in one... @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.textLabel.text = [self.tableData objectAtIndex:indexPath.row]; return cell; } Let’s start by looking at the method itself: -(UITableViewCell *)tableView:(UITableView *)tableView... basic table view stage by stage: To start, you created some data to display in the table Then, using Interface Builder, you created an instance of UITableView in the window The view controller conformed to the UITableViewDataSource and UITableViewDelegate protocols so that it could provide the data for the table, and the response to interaction You implemented the code required to create cells for the table. .. by instances of NSMutableArray, which is a subclass of NSArray): [array count]; 17 18 CHAPTER 1: Table Views from the Ground Up In STViewController.m, add the tableView:numbersOfRowsInSection: method, as shown in Listing 1–6 Listing 1–6 The tableView:numberOfRowsInSection: Method -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.tableData count]; }... sectioned The Plain Table The plain table is the basic vanilla incarnation of the UITableView Figure 2–3 shows an example (with possibly the dullest content imaginable) 27 28 CHAPTER 2: How the Table Fits Together Figure 2–3 A plain table view and its components The plain table is the version that is created by default, although the type can be specified: UITableView *tableView = [[UITableView alloc] . developer, chances are you’ll be using table views somewhere in your development projects. Table views are the bread and butter of iOS apps. With them, you can. http://developer.apple.com/library /ios/ #documentation/userexperience/concep tual/TableView_iPhone/AboutTableViewsiPhone/AboutTableViewsiPhone.html, or in Xcode’s

Ngày đăng: 05/03/2014, 22:21

TỪ KHÓA LIÊN QUAN