parentviewcontroller

How to transfer data between Parent and Child View Controllers

主宰稳场 提交于 2019-12-02 10:54:29
I have tried looking at answers on similar questions to this, but I am not particularly experienced and have had trouble following them, so any help would be much appreciated! My situation is as follows: when I press a button in my Parent ViewController, the following code is used to call a Child ViewController (by the way, the Child is actually a TableViewController, but it seems to work fine "thinking" it's a normal ViewController?): controller = (storyboard?.instantiateViewController(withIdentifier: "People")) addChildViewController(controller!) controller?.view.frame = CGRect(x: 10, y: 200

Only having one view autorotate in xcode?

六月ゝ 毕业季﹏ 提交于 2019-11-30 17:29:40
问题 Ok so I currently have 3 views and I need only one of them to autorotate to any orientation while the rest stay in portrait. Right now my set up is a splashviewcontroller fades into view A, and inside view A is a button to switch to view B. All I want is for view B to be able to rotate to any orientation. When I return YES for shouldautorotatetointerfaceorientation in the splashviewcontroller, every view rotates because this is the parent view. When I return portrait only in the splashview,

Container View Controllers - notify parent of action

删除回忆录丶 提交于 2019-11-30 02:26:14
Say I have a custom container view controller (MainViewController) where I do something like this: - (void)viewDidLoad { [super viewDidLoad]; HomeViewController *homeVC = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; [self addChildViewController:homeVC]; [self.view addSubview:homeVC.view]; } The HomeViewController will have a button, such as "go", that when pressed will need to advance to the next view controller. So I need to notify the MainViewController of this action. What is the best way to do this? I'm using a custom container because I need to do custom

Container View Controllers - notify parent of action

霸气de小男生 提交于 2019-11-28 23:21:21
问题 Say I have a custom container view controller (MainViewController) where I do something like this: - (void)viewDidLoad { [super viewDidLoad]; HomeViewController *homeVC = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; [self addChildViewController:homeVC]; [self.view addSubview:homeVC.view]; } The HomeViewController will have a button, such as "go", that when pressed will need to advance to the next view controller. So I need to notify the MainViewController of

Add a child view controller's view to a subview of the parent view controller

一个人想着一个人 提交于 2019-11-27 12:04:52
I want to add a tableViewController as a child view controller of a containerViewController (shown below). According to Apple's View Controller Programming Guide I can achieve this by the following lines of code inside my containerViewController: [self addChildViewController:tableViewController]; [self.view addSubview:tableViewController.view]; [tableViewController didMoveToParentViewController:self]; In fact, that works fine. Now the problem is that I do not want to add the tableViewController's view as a subview of the containerViewController's root view. Instead I want to add it as a