Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add "Edit" button to UIViewController

Tags:

ios

swift

I am familiar with this code: self.navigationItem.leftBarButtonItem = self.editButtonItem.

See this code:

class ThirdViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet var tblTasks: UITableView! // declaring this allows you to reload the tableView to update your items

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationItem.rightBarButtonItem = self.editButtonItem()
}

I have the code that allows for the edit button to be present, yet no edit button is to be seen in my app nor the storyboard.

I am a Swift beginner, if someone could point me in the right direction that would be awesome.

like image 343
MortalMan Avatar asked Oct 27 '25 01:10

MortalMan


1 Answers

The stock "Edit" button is only available on UITableViewController. For other view controller types you'll have to create a button yourself.

like image 79
bgilham Avatar answered Oct 29 '25 18:10

bgilham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!