01.02.2014 Views

Objective-C Fundamentals

Objective-C Fundamentals

Objective-C Fundamentals

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Important protocols<br />

157<br />

or in tableView:cellForRowAtIndexPath:, but that isn’t the case. When the<br />

UITableView is delivered a UITableViewCell, Apple modifies certain parts of the cell<br />

to make it fit nicely into the UITableView. When the table view is completely done<br />

doing what it needs to do with the cell, it passes the cell through the following method<br />

for any final modifications. After this method finishes, the cell is put into the table<br />

view and displayed to the user:<br />

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

willDisplayCell:(UITableViewCell *)cell<br />

forRowAtIndexPath:(NSIndexPath *)indexPath<br />

7.3.3 <br />

The UIActionSheet is a great interface element provided by Apple. It’s used either to<br />

inform the user of an alert that takes over an entire application or to provide a<br />

prompt that a process is being conducted for the user. Examples of this include choosing<br />

a language for an application’s content and informing a user that an application is<br />

uploading some kind of file. Action sheets have a protocol associated with them to<br />

inform the presenting view controller of their activity. Let’s look at the methods that<br />

compose the .<br />

The following method is called when a button from the UIActionSheet is pushed.<br />

After this method executes, the UIActionSheet is automatically dismissed. Here you<br />

respond appropriately to whatever button was selected but don’t have to worry about<br />

returning anything or dismissing the action sheet. That’s all taken care of automatically:<br />

- (void)actionSheet:(UIActionSheet *)actionSheet<br />

clickedButtonAtIndex:(NSInteger)buttonIndex<br />

The following methods are available, providing hooks into the application flow. will-<br />

PresentActionSheet: is called just before the action sheet animation begins, and<br />

didPresentActionSheet: is called as the animation finishes. These different access<br />

points allow developers to get the kind of responsiveness that they’re shooting for:<br />

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet<br />

- (void)didPresentActionSheet:(UIActionSheet *)actionSheet<br />

Like the presentation methods, the following methods provide hooks into the action<br />

sheet when it’s being dismissed. The actionSheet:willDismissWithButtonIndex: is<br />

called just before the action sheet dismissal animation begins, and actionSheet: did-<br />

DismissWithButtonIndex: is called as the dismissal animation finishes:<br />

- (void)actionSheet:(UIActionSheet *)actionSheet<br />

willDismissWithButtonIndex:(NSInteger)buttonIndex<br />

- (void)actionSheet:(UIActionSheet *)actionSheet<br />

didDismissWithButtonIndex:(NSInteger)buttonIndex<br />

The following is the final method you need to implement when creating an action<br />

sheet, and it might not be necessary every time you make one. Action sheets, when<br />

they’re being created, allow developers to set a “destructive button title.” If a developer

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

Saved successfully!

Ooh no, something went wrong!