Reputation: 611
I have a little problem, I want to add a function to two BarItems
in my UINavigationBar
, which is placed above the UITableView
in a normal ViewController
. I'm very new to programming so can you please give me the complete code that I need? The functions I want to have are:
UITableView
. Maybe also a function that points to another ViewController
where I can type the data for Title and subtitle to save it afterwards.Thanks!
Upvotes: 0
Views: 553
Reputation: 8396
For editing record:
You cannot get the cell that your planning to edit using button on UINavigationController
, the buttons should be placed at the same cell on your UITableview
to edit that specific cell. and in this way you need custom UITableviewcell
.
For creating new record :
First link the button to your UIViewController
class as Action.
You can append the array that your using to fill the UITableview
and then call your UITableview
like to refresh the data:
self.tableview.reloadData()
For presenting another UIViewController
:
First drag new ViewController
in your storyboard
and link the button on the first ViewController
into your new UIViewController
and choose segue as "Show".
To save your data its a big topic you have either NSUserDefaults
or CoreData
so Google it.
Note : linking means by pressing ctrl-drag with mouse to your target.
Update :
Download your sample from here : https://yadi.sk/d/EJf610XWhkxDT
Upvotes: 3