views:

83

answers:

3

hi,

how can i access a subview i added in another view controller? Like

DummyViewController:

- Subview 1
- Subview 2

TestViewController:

- Subview 3

Now I want to access the properties of Subview 1 (DummyViewController) in Subview 3 (TestViewController).

Thank + Regards

A: 

Put or send the shared properties in another object above both dummyviewcontroller and testviewcontroller (the M of the MVC pattern) and pass a reference to that model object down to whoever needs those properties.

Or have whatever is above those two view controllers put a reference to the dummyviewcontroller into the testviewcontroller subview.

hotpaw2
any code samples?
Tronic
A: 

import "DummyViewController.h"

DummyViewController *dummy = [[DummyViewController alloc] init];

dummy.subview1.button.hidden = NO;

Here I am accessing the button of subview1 in testviewcontroller.

hope this works for u...

kool4u
i tried that, but that doesn't gives me the current instance of that view!
Tronic
A: 

In "DummyViewController" in viewDidLoad

subView1.tag = 1;
subView2.tag = 2;

In TestViewController

DummyViewController *dummy = [[DummyViewController alloc] init];
UIView subview1 = [dummy.view viewWithTag:1];
does this get me the same instance?
Tronic