I have a ViewController which consist of UILabel
and UIButton
. OnClick UIButton
a popOver
present which show tableView
. each cell of tableView
represent different font option.
I want to change the font of UILabel
based on user selected font from tableViewCell
. how i can achieve this as my UILabel
and tableView
are in different viewController class.
Please help me.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var row = indexPath.row
// How to update label from here
}
Edit : I fond this answer but not able to understand as its return in objective c update ViewController label text from different view
You can use delegate. In your
popover
Swift file create such protocol:In your
popover
class create such implementation of newly created protocol:Now in your main view controller, if you are presenting your
popover
programmatically, you should set your popover'sdelegate
property toself
. If your are presenting popover from storyboard, just handle segue:Now implement delegate method:
And of course don't forget to add delegate to your main view controller:
Hope it helps!