Skip to content

Instantly share code, notes, and snippets.

@wagyu298
Created June 19, 2013 00:58
Show Gist options
  • Save wagyu298/5810889 to your computer and use it in GitHub Desktop.
Save wagyu298/5810889 to your computer and use it in GitHub Desktop.
didSelectItemAtIndexPath of MainViewController.m from iPhone flat design UI http://www.appdesignvault.com/iphone-flat-ui-design-patterns/.
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
StoryboardInfo* storyboardInfo = self.storyboards[indexPath.section];
ControllerInfo* controllerInfo = storyboardInfo.controllers[indexPath.row];
self.currentViewController = [self getControllerFromStoryboardInfo:storyboardInfo andControllerInfo:controllerInfo];
UIViewController* controller = self.currentViewController;
controller.view.frame = CGRectMake(0, 0, controller.view.frame.size.width, controller.view.frame.size.height);
[controller.view addGestureRecognizer:self.swipeGesture];
CGFloat yOffset = [controller isKindOfClass:[UINavigationController class]] ? -20 : 0;
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:controller.view animated:YES];
hud.labelText = @"Swipe right to dismiss";
controller.view.frame = CGRectMake(320, yOffset, controller.view.frame.size.width, controller.view.frame.size.height);
[self.view addSubview:controller.view];
[UIView animateWithDuration:1.0
delay:0.0
options: UIViewAnimationOptionCurveEaseInOut
animations:^{
controller.view.frame = CGRectMake(0, yOffset, controller.view.frame.size.width, controller.view.frame.size.height);
}
completion:^(BOOL finished){
[MBProgressHUD hideHUDForView:controller.view animated:YES];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment