01.02.2014 Views

Objective-C Fundamentals

Objective-C Fundamentals

Objective-C Fundamentals

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Important protocols<br />

155<br />

Any table view (grouped or standard) may have a<br />

header view. This view can be anything: a single<br />

UIView, UIImageView, or UILabel, for instance, or<br />

a more complex custom UIView subclass. Using the<br />

header view delegate method saves a number of<br />

lines of code required to customize the headers,<br />

and generally is a better practice than attempting<br />

to implement a header yourself. If you have a reason<br />

to add some type of custom view before your<br />

table data is shown, these are the methods you<br />

should implement:<br />

- (CGFloat)tableView:(UITableView *)tableView<br />

heightForFooterInSection:<br />

(NSInteger)section<br />

- (UIView *)tableView:(UITableView<br />

*)tableView<br />

viewForFooterInSection:(NSInteger)section<br />

This set of methods is identical to the header view<br />

methods and likewise must be implemented<br />

together. Once again, this is the best practice<br />

when you need to add some custom content after<br />

your table view section data is presented.<br />

Figure 7.1 Setting an indentation level<br />

for a table view<br />

ACTION METHODS<br />

Most methods that a class conforming to the<br />

can implement are methods<br />

that respond to events that occur in the table view. These methods will inform you<br />

of things like cells being added, cells being removed, cells being modified, cells being<br />

selected, and a few more types of events that can occur:<br />

- (void)tableView:(UITableView *)tableView<br />

accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath<br />

Apple provides some standard-style accessory views for UITableViewCells. Accessory<br />

views are placed on the right-hand side of a UITableViewCell. They’re distinct parts<br />

of a cell that can be hidden or modified when a table view is being edited. UITable-<br />

ViewCellAccessoryTypes come in four default flavors:<br />

■<br />

■<br />

UITableViewCellAccessoryNone<br />

This method leaves the accessory view of the UITableViewCell blank. This is<br />

the default set for UITableViewCells.<br />

UITableViewCellAccessoryDisclosureIndicator<br />

This method leaves the accessory view of the UITableViewCell as a bold<br />

greater-than sign.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!