Home UIBarButtonItem still selected/highlighted after unwind segue
Reply: 2

UIBarButtonItem still selected/highlighted after unwind segue

symenize Published in 2017-12-07 22:31:15Z

Small question here.

I have an UIBarButtonItem which makes a segue to another table view. When the user is done here I've implemented a unwind segue back to the first table view. Everything works fine except for the fact that the UIBarButtonItem is still selected/highlighted after the unwind segue which can be seen here. I have no idea why this is the case and was wondering how I could fix this?

Thanks in advance.

Edit: I meant this when I said it was embedded

DevB2F Reply to 2017-12-08 16:38:27Z

Using a navigation controller might be causing this. Using the popToViewController might solve the problem. Just replace MyViewController with the VievController you want to go to.

let vc = self.navigationController?.viewControllers

for v in vc! {

    print("viewcontroller is: \(v)")
    if v as? MyViewController != nil {
        self.navigationController?.popToViewController(v, animated: false)
symenize Reply to 2017-12-12 08:31:18Z

For anyone still trying to figure out how to solve this here is a quick work around. Go to your unwind segue method en put the following code in there:

 if self.navigationItem.rightBarButtonItem?.style == .plain {
        self.navigationItem.rightBarButtonItem?.style = .done
 if self.navigationItem.rightBarButtonItem?.style == .done {
        self.navigationItem.rightBarButtonItem?.style = .plain

It may not work for all cases but it worked for me. (I don't really know why it works though)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.555111 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO