2

I am using storyboard in my app where I have to navigate to another view controller without animation.I am successfully doing it using the custom segue.But I when I come back to the previous view controller then by using navigation bar default back button then it is animating while coming backward.So going forward it is not animating and going backward it is animating.I want to stop the default animation of the back button.

Custom Seague

// PushNoAnimationSegue.h

@interface PushNoAnimationSegue : UIStoryboardSegue

@end

// PushNoAnimationSegue.m

@implementation PushNoAnimationSegue

-(void) perform{
    [[[self sourceViewController] navigationController] pushViewController:[self   destinationViewController] animated:NO];
}

@end

Using this code I am successfully going to the next view controller without animation since -(void) perform is called automatically in the forward direction.When I come back it is not called.So please suggest me if there is anything wrong with the implementation or I should go with some other method.

Imran
  • 1,715
  • 2
  • 20
  • 42
  • This question may be helpful: http://stackoverflow.com/questions/6091867/find-out-if-user-pressed-the-back-button-in-uinavigationcontroller – Pushparaj Aug 14 '14 at 11:25

2 Answers2

1

hope this will help

1.custom button on navigation bar

UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(x,y,width,height)];
[btn setImage:[UIImage imageNamed:@"some_image.png"] forState:UIControlStateNormal];

[btn addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.leftBarButtonItem =backButtonItem;

and then

void popViewController()
{
[self.navigationController popViewControllerAnimated:NO];
}
Anurag Bhakuni
  • 2,379
  • 26
  • 32
0

If you use NavigationController then use this

[self.navigationController popViewControllerAnimated:NO];

Or

[self dismissViewControllerAnimated:NO completion:nil];
BHASKAR
  • 1,201
  • 1
  • 9
  • 20