0

I have an iOS project with UINavigationController. When I pushviewcontroller with

animated = YES

[self.navigationController pushViewController:viewController animated:YES];

the top leftbarbuttonitem (with image) is well positioned. But if I set pushviewcontroller with

animated = NO

[self.navigationController pushViewController:viewController animated:NO];

the top leftbarbuttonitem (with image) is not positioned exactly the same place with previous one. Does anyone have any idea?

SAMPLE CODE

- (void)addBackButtonWithoutAnimation {
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

UIImage *closeImage = [UIImage imageNamed:@"icon_back"];
UIBarButtonItem *closeBackButton = [[UIBarButtonItem alloc] initWithImage:closeImage style:UIBarButtonItemStylePlain target:self action:@selector(closeBackButtonwithoutAnimationDidClick)];

self.navigationItem.leftBarButtonItem = closeBackButton;
self.navigationItem.hidesBackButton = YES;}
10
  • Have you done any customization to the back button? like replaced with image or something? Commented Jan 4, 2019 at 3:35
  • Yes, replace with image Commented Jan 4, 2019 at 3:40
  • can you paste the code and where you put it? Commented Jan 4, 2019 at 4:02
  • Done Edited my post =) Commented Jan 4, 2019 at 4:05
  • in the ViewDidLoad you call for addBackButtonWithoutAnimation right? Commented Jan 4, 2019 at 4:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.