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

JamesFoote

macrumors regular
Original poster
Aug 5, 2008
109
0
My app currently has a menu (that is not the mainview so it can't even be seen yet) and another 2 files (rootviewcontroller and mainview) that make up an RSS reding view. I want to be able to do 2 things:

1. Make the menu the mainview
2. Link one of the buttons on the mainview to the RSS view

anyone who can help me out with this rocks - a whole lot!!!
 

usuf24

macrumors newbie
Aug 21, 2008
7
0
My app currently has a menu (that is not the mainview so it can't even be seen yet) and another 2 files (rootviewcontroller and mainview) that make up an RSS reding view. I want to be able to do 2 things:

1. Make the menu the mainview
2. Link one of the buttons on the mainview to the RSS view

anyone who can help me out with this rocks - a whole lot!!!

Hi can you be more clear!!

Anyways from what I have understood from the above quest, u want to make some view as the mainview and u wanna traverse from the mainview to the RSS View, if am not wrong..

for your first question : In order to make any view to be displayed first, it shld have a WINDOW in its class declaration and its NIB file shld be mentioned as the first NIB in the pInfo.list file if you are using the IB..

for ur second quest: Just create an Instance of that view controller which you wanna goto and then add its view as a subview to the mainview's window....

Regards,
Usuf
 

iphonejudy

macrumors 6502
Sep 12, 2008
301
1
Hi ,

I use the below code ,But its not working.
Can you please tell me what is the error in the code?

#import "TestViewController.h"
#import "Test2ViewController.h"


@implementation TestViewController
@synthesize view2Controller;

-(IBAction)display:(id)sender
{




//Load the view controller from the HelloView nib file.
Test2ViewController *vController = [[Test2ViewController alloc]
initWithNibName:mad:"Test2View" bundle:[NSBundle mainBundle]];

//set the view.
self.view2Controller = vController;

//release the view controller.
[vController release];


}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Initialization code
}
return self;
}





// If you need to do additional setup after loading the view, override viewDidLoad.
- (void)viewDidLoad {



Test2ViewController *view2 = [[Test2ViewController alloc] initWithNibName:mad:"Test2View" bundle:[NSBundle mainBundle]];
self.view2Controller = view2;
[view2 release];

}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}


- (void)dealloc {
[super dealloc];
}


@end
Thanks
judy
 

usuf24

macrumors newbie
Aug 21, 2008
7
0
Traversing through views

Hi,


U are not adding ur newly created view controller's view to the window.

so just use [window addSubView:viewController.view]; after u create the view controller's instance............in ur IBAction display......


Regards,

U'suf
 

iphonejudy

macrumors 6502
Sep 12, 2008
301
1
Hi

When i run the application.The view2 is not displayed.I got the following warning message.

warning: 'UIWindow maynot respond to -addSubView'

Here my code is,

Code:
-(IBAction)display:(id)sender
{
	//Load the view controller from the HelloView nib file.
	Test2ViewController *vController = [[Test2ViewController alloc] 
										initWithNibName:@"Test2View" bundle:[NSBundle mainBundle]];
		//set the view.
	self.view2Controller = vController;
	
	//release the view controller.
	[vController release];
	
	

	[window addSubView:view2Controller.view];

    [window makeKeyAndVisible];
}

Can anybody please tell me the solution?

Thanks
judy
 

usuf24

macrumors newbie
Aug 21, 2008
7
0
Hi,

use [self.view.window addSubView:viewController.view];

Regards,

usuf
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.