سؤال

It might be really simple, in that case sorry.

I'm adding a SplitViewController to my app. Everything works fine except for the View loaded in detailView; It does load (the controls, etc), but the data stays "blank", like it's not getting data from the database.

But it is, the view itself is responsible for it, and it works when I don't insert it in the detailViewController !

Check it out :

//this is my data and my ViewController
Medication* med = self.medications[indexPath.row]; 
MedicationViewController* viewController = [[MedicationViewController alloc] initWithMedication:med isNew:NO];

//1. this *doesn't work*, the detail panel get replaced, but the data from "med" never appears
self.detailViewController = viewController;

//2. but if I do this, everything works fine.
[self presentViewController:viewController animated:YES completion:nil];

My guess is, my replacement (1.) is done wrong. Any comments ? Am I missing a "refresh", "reload" function ?

هل كانت مفيدة؟

المحلول

Finally, I got it working by doing this :

UINavigationController* detailNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
self.splitViewController.viewControllers = @[self.splitViewController.viewControllers[0], detailNavController];

instead of changing only one controller, you change the whole array, but keeping the same reference to the master. Works well !

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top