iphone - IOS Swift - Passing data between view controllers using container view -
i little confused on how use container views correctly, try explain best can.
i have main view controller has animation function.
import uikit class mainviewcontroller: uiviewcontroller,uipickerviewdatasource,uipickerviewdelegate { // run view setups override func viewdidload() { super.viewdidload() } func closepicker(){ self.view.layoutifneeded(); uiview.animatewithduration(0.5, animations: { self.countrypickerconst.constant = -206; self.view.layoutifneeded(); }) } }
in interface builder have added container view new view controller contains button so:
import uikit class containerviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() // additional setup after loading view. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func runanimation(sender: uibutton) { //i want call function in other view controller } }
in action runanimation want call function in mainviewcontroller. if create instance of mainviewcontroller , call function seems loose 'self' relevance.
if explain me best practice doing things great.
thanks
from explanation mainviewcontroller
parent of containerviewcontroller
access closepicker
containerviewcontroller
do:
@ibaction func runanimation(sender: uibutton) { (self.parentviewcontroller as! mainviewcontroller).closepicker() }
Comments
Post a Comment