Because of UI elements, I created View Controller with a TableView inside. But I can't enable editing mode. I tried several methods without Solution. But with using TableView Controller there are no problems.
What I tried:
override func viewDidLoad() {
self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func setEditing(editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if (editingStyle == UITableViewCellEditingStyle.Delete) {
// Action to delete data
}
}
Where can be the problem?
Right-click the control or object in your current view controller. Drag the cursor to the view controller you want to present. Select the kind of segue you want from the list that Xcode provides.
One way to do this is programmatically create an UIScrollView in your UIViewController . To control the scrollability you can set the ScrollView contentSize property.
A view controller manages a single root view, which may itself contain any number of subviews. User interactions with that view hierarchy are handled by your view controller, which coordinates with other objects of your app as needed. Every app has at least one view controller whose content fills the main window.
You forgot to put the table view in editing mode:
override func setEditing(editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
self.tableView.setEditing(editing, animated: animated)
}
I'm assuming you have a tableView
property. Adjust as needed.
Some other things you may want to do to emulate a UITableViewController
:
viewWillAppear
you should deselect the currently selected row in the table view.viewDidAppear
you should flash the scrollbars of the table view.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With