0

I have UINavigationController with 2 view controllers vc1 and vc2 (vc1 pushes vc2). I need to set back button title of vc2, so I do it by:

vc1.navigationItem.backBarButtonItem 
       = UIBarButtonItem(title: title, style: .plain, target: nil, action: nil)

But this back button title is a counter, I get it from Database, so I usually set it after viewWillAppear but before viewDidAppear (it happens during navigation controller transition from vc1 to vc2)

But the back button title is applied only after the transition is completed. As a comparison if I use leftBarButtonItem with custom view, the title is applied before the transition is completed. But I'm not allowed to use leftBarButtonItem

Here is the Video how it looks like (it's possible to notice if you scroll video slowly)

Is it possible somehow to force update back button title before the transition is completed?

Paul T.
  • 4,938
  • 7
  • 45
  • 93
  • Have you tried applying it when you init vc2? – Wez Jan 30 '20 at 15:37
  • it's too early to apply it on init (cause there is no id to extract from DB, but I tried applying it on viewDidLoad - didn't help, I anyway get a counter between viewWillAppear and viewDidAppear – Paul T. Jan 31 '20 at 06:39

0 Answers0