Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-05-2009, 12:12 AM   #1 (permalink)
iPhone Neophyte
 
Join Date: Mar 2009
Posts: 41
Default Switching between view controllers

Is it necessary to use a third dedicated UIViewcontroller for navigation between 2 view controllers, or can an app be programmed to call another viewcontroller into view when, say, a UIButton is pushed?

Apologies in advance for simple question.
erfmufn is offline   Reply With Quote
Old 04-05-2009, 01:33 AM   #2 (permalink)
iPhone Neophyte
 
Join Date: Mar 2009
Posts: 41
Default

Well through some trial and error I've worked out I don't need a third controller and I can call a switch method in the delegate which is pretty neat. Now my only problem is that it ignores the landscape orientation I've set.

Code:
- (void)switchView 
{
    if (instructionsViewController == nil)
    { 
        [viewController.view removeFromSuperview];
        [viewController release];
        viewController = nil;
		
        instructionsViewController = [[InstructionsViewController alloc]init];
        [window addSubview:instructionsViewController.view];
    }
    else
    {
        [instructionsViewController.view removeFromSuperview];
		[instructionsViewController release];
		instructionsViewController = nil;
		
		viewController = [[PianoTutorViewController alloc]init];
        [window addSubview:viewController.view];
    }
}
Not sure if code is elegant, but works apart from the landscape issue.
erfmufn is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,295
Threads: 89,032
Posts: 379,808
Top Poster: BrianSlick (7,086)
Welcome to our newest member, y0ut0be44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:49 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0