Graphics Programs Reference
In-Depth Information
At that point, the DetailViewController will pass this block to dismis-
sViewControllerAnimated:completion: . In DetailViewController.m ,
modify the implementations of save: and cancel: to send the message dismis-
sViewControllerAnimated:completion: with dimissBlock as an argu-
ment.
- (IBAction)save:(id)sender
{
[[self presentingViewController] dismissViewControllerAnimated:YES
completion:nil];
[[self presentingViewController] dismissViewControllerAnimated:YES
completion:dismissBlock];
}
- (IBAction)cancel:(id)sender
{
[[BNRItemStore sharedStore] removeItem:item];
[[self presentingViewController] dismissViewControllerAnimated:YES
completion:nil];
[[self presentingViewController] dismissViewControllerAnimated:YES
completion:dismissBlock];
}
Build and run the application. Tap the button to create a new item and then tap Done . The
new BNRItem will appear in the table.
Once again, don't worry if the syntax or the general idea of blocks doesn't make sense at
this point. Hold on until Chapter 27 , and we will hit all the gory details there.
Modal view controller transitions
In addition to changing the presentation style of a modal view controller, you can change
the animation that places it on screen. Like presentation styles, there is a view controller
property ( modalTransitionStyle ) that you can set with a pre-defined constant. By
default, the animation will slide the modal view controller up from the bottom of the
screen. You can also have the view controller fade in, flip in, or appear underneath a page
curl (like in the Maps application).
In ItemsViewController.m , update the addNewItem: method to use a different
transition.
[navController setModalPresentationStyle:UIModalPresentationFormSheet];
[navController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:navController animated:YES completion:nil];
 
Search WWH ::




Custom Search