Trying to make rightBarButton appear after making it disappear using Swift

syedfa

I currently am working on an app in Swift where in my viewDidLoad() method I have purposely hidden my rightBarButton on my navigation bar like this:

self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Done, target: self, action: #selector(TableViewController.dismiss))
self.navigationItem.setRightBarButtonItem(nil, animated: true)

However, under certain circumstances, I would like to display the rightBarButton. How would I do this? What would be the opposite of the above line of code?

Josue Espinosa

Once you set the bar button item to nil, it is gone. Something you can do however, is store the bar button item like so:

let barButtonItem = UIBarButtonItem(barButtonSystemItem: .Done, target: self, action: #selector(TableViewController.dismiss));

and then you can make it appear/disappear like so:

self.navigationItem.rightBarButtonItem = barButtonItem
self.navigationItem.setRightBarButtonItem(nil, animated: true)

then just access the barButtonItem whenever you want it to appear/disappear.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to Make Canvas Text Appear and Disappear in Tkinter Using .after

use css to make object appear, then after delay, make it disappear

Making elements appear and disappear loop

Swift How to make the previous label disappear and the new one to appear

Make images appear randomly and disappear after certain time

How to use DispatchQueue to make a view appear and disappear after some time?

Using Flask and Python - can't make messages appear and disappear

Make a UIBarButtonItem disappear using swift IOS

Make object disappear and appear in OpenGL

Make div appear or disappear with javascript

How to make divs appear and disappear?

Swiping to make ImageButton disappear / appear

make a shape appear and disappear on click

Making GameObject appear and disappear for a finite amount of time

Bootstrap time is disappear after appear

Making Imageview disappear After Animation

How to make a UIImageView photo disappear after a time interval in Swift

Trying to make a div disappear with javascript

Make <p> disappear after certain amount of time using JS or JQuery

How to make screensaver to appear and disappear based on time?

How to make an image appear and disappear randomly?

Pygame, how to make circle disappear and appear with MOUSEBUTTONDOWN?

Button will not appear or will disappear after being clicked

How to make rect's disappear and re-appear using onclick buttons

Javascript for making the element disappear and reappear after scroll

Making jQuery tooltip disappear after 2 seconds

Make UIButton disappear after clicking it?

Showing error message using jQuery and making it disappear

Making a parent node disappear using javascript