I’m having a bit of an issue here switching between my view controllers.
I followed the advice on this page:
View Controllers: How to switch between views programmatically?
My setup is as follows; I have a splash screen with a button on it and that button loads my second view controller. I have IntroductionViewController as the root view and the button says “Load Website”, this Load Website event I want to switch to WebsiteViewController.
On IntroductionViewController I have set up the button as an IBOutlet and IBAction which is NSLogging fine on Click so I know the method is working.
What I need is when you click Load Website it opens WebsiteViewController. What I have so far is credit of the question above:
IntroductionViewController.h
#import <UIKit/UIKit.h>
#import "WebsiteViewController.h"
@class WebsiteViewController;
@interface IntroductionViewController : UIViewController {
IBOutlet UIButton *websiteButton;
IBOutlet WebsiteViewController *websiteViewController;
}
@property (nonatomic, retain) UIButton *websiteButton;
@property (nonatomic, retain) WebsiteViewController *websiteViewController;
-(IBAction)loadWebsite:(id)sender;
@end
IntroductionViewController.m
#import "IntroductionViewController.h"
@implementation IntroductionViewController
@synthesize websiteButton;
@synthesize websiteViewController;
-(IBAction)loadWebsite:(id)sender{
if(self.websiteViewController.view.superview == nil)
{
[self.view addSubview:websiteViewController.view];
}
}
The line: [self.view addSubview:websiteViewController.view]; doesn’t do anything, but as I’ve said previously, this function is NSLogging fine. I’m not sure how to proceed with this.
Possible you may have forgot to bind the IBOutlet to your WebsiteViewController. And for both Orientation support you can use
One more thought for your orientation problem, you can setFrame to your view while displaying like
May be this works.
Thax.