Created
February 2, 2014 10:42
-
-
Save roothybrid7/8766306 to your computer and use it in GitHub Desktop.
Segueを使ってUINavigationControllerの画面遷移アニメーションを変更する ref: http://qiita.com/roothybrid7/items/532b63175da30fa9a2b1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "MasterViewController.h" | |
#import "DetailViewController.h" | |
#import "MyNavigationController.h" | |
#import "NavigateFlipSegue.h" | |
@interface MasterViewController () <MyNavigationControllerDelegate> // 委譲用プロトコルの適用 | |
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath; | |
@end | |
@implementation MasterViewController | |
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | |
{ | |
if ([[segue identifier] isEqualToString:@"showDetail"]) { | |
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; | |
NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath]; | |
[[segue destinationViewController] setDetailItem:object]; | |
} | |
} | |
// unwind segueの定義 | |
- (IBAction)exitToMasterView:(UIStoryboardSegue *)segue | |
{ | |
// XXX: No-op. unwind segue. | |
} | |
#pragma mark - MyNavigationControllerDelegate | |
// 委譲用プロトコルメソッドの実装 | |
- (UIStoryboardSegue *)segueInNavigationControllerForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier | |
{ | |
if ([identifier isEqualToString:@"existFromDetail"]) { // custom segueの生成 | |
NavigateFlipSegue *segue = [[NavigateFlipSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController]; | |
segue.unwind = YES; // unwind segueなのでセット | |
return segue; | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment