ios - How to pass Data to a ViewController created using instantiateViewControllerWithIdentifier? -
i've created app uses bunch load of container views. today i've found out embedded segues not supported in ios 5 (thanks xcode letting me know.) right have lot of embedded segues passes data between 1 another.
i'm using code load viewcontrollers inside uiview instead of container ib:
rootviewcontroller:
- (void)viewdidload { [super viewdidload]; uistoryboard* storyboard = [uistoryboard storyboardwithname:@"mainstoryboard" bundle:nil]; newsviewcontroller *news = [storyboard instantiateviewcontrollerwithidentifier:@"newsviewcontrollerid"]; news.view.frame = self.newssection.bounds; [self.newssection addsubview:news.view]; [self addchildviewcontroller:news]; [news didmovetoparentviewcontroller:self]; // additional setup after loading view. }
how can use above , still pass data newsviewcontroller (something prepare segue)
i've tried inserting in above like
newsviewcontroller *news = [storyboard instantiateviewcontrollerwithidentifier:@"newsviewcontrollerid"]; news.view.frame = self.newssection.bounds; news.mylabel.text = @"test"; [self.newssection addsubview:news.view];
but label won't change.
i prefer pass data , not use singleton or delegation.
thanks
i recommend creating public method, pass data need on newsviewcontroller
controller. still, issue right updating ui before has been initialised. recommend have on how create content uiviewcontrollers
, because right adding uiview
. check this document apple, @ section implementing custom container view controller. , part of code:
- (void) displaycontentcontroller: (uiviewcontroller*) content; { [self addchildviewcontroller:content]; // 1 content.view.frame = [self frameforcontentcontroller]; // 2 [self.view addsubview:self.currentclientview]; [content didmovetoparentviewcontroller:self]; // 3 }
so in case, after step 3 has been made, pass values want use inside newsviewcontroller
.
Comments
Post a Comment