Reputation: 37
I have one viewController that has two segment view. as the below pic shows I want to press refresh button (top left) and effect inside the segment viewColler in swift.
i couldn't add refresh button inside the segmentViewController, so is there a way to call function from fristViewController to segmentViewController by pressing refresh button ? or via prepareForSegue func ? P.S: viewDidLoad get some information online, by pressing refresh button this shown data will be refreshed.
I handle the segment change value like this
@IBOutlet weak var segment1: UISegmentedControl!
@IBAction func indexChanged(sender: AnyObject) {
switch segment1.selectSegmentIndex
{
case 0:
firstView.hidden = false
secondView.hidden = true
case 1:
firstView.hidden = true
secondView.hidden = false
default:
break;
}
}
I appreciated.
Upvotes: 0
Views: 1255
Reputation: 22651
Somewhere in firstViewController, there must be a function which handles a tap on the segmented control (perhaps it's called valueChanged
). If you add a property to firstViewController:
var activeSegmentViewController: segmentViewController
and keep track of which segmentViewController is the active one in the valueChanged
function, you can use that property to call the function:
activeSegmentViewController.refresh()
Upvotes: 2