Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
Hi ,
I have in my .xib file two views,
one is the main view that connected to the view outlet from the file's owner and
the second one I named ABC from the code

-IBOutlet UIView *ABC;

my question is how do I call the ABC view from another class if ABC view isn't
connected to the "view" outlet from the file's owner

I can call the main view from another class

Code:
	LoginRegisterViewController *viewController = [[LoginRegisterViewController alloc] initWithNibName:@"LoginRegisterViewController" bundle:nil];
	self.loginRegisterViewController = viewController;
	[viewController release];

 UIView *newView = loginRegisterViewController.view;
    [self.view addSubview:newView];
    [newView release];

but I don't know how to call the ABC view.
maybe I can use the ABC view as a @property and call it from the other class?

Thanks for the help!!!
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Same way you would any other member variable of a class. Either make it a property and synthesise the accessors or write your own accessors.
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
UIView *newView = loginRegisterViewController.abc;

It's shows me blank view
what is the problem?
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
abc class
.h
Code:
-IBOutlet UIView *abc
Code:
@property(nonatomic,retain)   IBOutlet UIView *abc;
.m
Code:
@synthesize abc;



other class
Code:
LoginRegisterViewController *viewController = [[LoginRegisterViewController alloc] initWithNibName:@"LoginRegisterViewController" bundle:nil];
	self.loginRegisterViewController = viewController;
	[viewController release];

 UIView *newView = loginRegisterViewController.abc;
    [self.view addSubview:newView];
    [newView release];
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
And that's still correctly connected in Interface Builder? If you check the value of abc in awakeFromNib inside LoginRegisterViewController is it nil?
 

Nnavick

macrumors regular
Original poster
Oct 13, 2010
100
0
And that's still correctly connected in Interface Builder? If you check the value of abc in awakeFromNib inside LoginRegisterViewController is it nil?

yep,it's nil,I haven't call it before.

Dejo,I don't see any problem releasing newView(?)
 

Sykte

macrumors regular
Aug 26, 2010
223
0
Code:
	LoginRegisterViewController *viewController = [[LoginRegisterViewController alloc] initWithNibName:@"LoginRegisterViewController" bundle:nil];
	self.loginRegisterViewController = viewController;
	[viewController release];

 UIView *newView = loginRegisterViewController.view;
    [self.view addSubview:newView];
    [newView release];

You will save time by reading the documentation. The code above could easily be 2 lines instead of 6. Don't rush learning the basics.
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.