Pepijn Hoff
Pepijn Hoff

Reputation: 1

Switching to RootViewController

I've got 2 different xcode projects. one is the main app, it's got the full design ready etc. and switches some screens. Then I've got an location app which show you the nearby hospitals etc. What I wanted it to do is if I press a button in the main app it goes to the location app. So I combined the two projects in one. finally it worked but now when trying to link the location app to the button it works but it doesn't show me the full screen. It just shows me a table with hospital, doctor etc. but i want to see the full screen of the location app. And i thought it was the rootviewcontroller. Here is the code:

.h file

#import <UIKit/UIKit.h>
#import "VacaturesViewController.h"
#import "Over.h"
#import "RootViewController.h"
#import <CoreData/CoreData.h>
#import "NewKeywordViewController.h"

@interface Home : UIViewController {

//UI Button instance variable
UIButton *tweetButton;



}

// Properties
@property (nonatomic, strong) IBOutlet UIButton *tweetButton;




// Methods
-(IBAction)sendTweet:(id)sender;
-(IBAction)vacatures;
-(IBAction)zoeken;
-(IBAction)Over;

And the .m file:

#import "Home.h"
#import "RootViewController.h"
#import "Reachability.h"
#import "AppDelegate.h"
#import "MapViewController.h"
#import "InfoViewController.h"
#import "Keyword.h"





@interface Home ()

@end

@implementation Home

@synthesize tweetButton;




-(IBAction)vacatures {

    VacaturesViewController *screen = [[VacaturesViewController alloc] initWithNibName:nil       bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:screen animated:YES];


}

-(IBAction)zoeken {

RootViewController *screen = [[[RootViewController alloc] initWithNibName:nil bundle:nil]   autorelease];
[self presentModalViewController:screen animated:YES];

}

-(IBAction)Over {

Over *screen = [[Over alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:screen animated:YES];


}





-(IBAction)sendTweet:(id)sender
{
NSString *tweet = [[NSString alloc] initWithString:@"Door de Thuiszorg applicatie heb ik   altijd de juiste zorg in de buurt! Downloaden dus!"]; // Creates the string that is used for the tweet.
{
    TWTweetComposeViewController *tweeter = [[TWTweetComposeViewController alloc] init];    // Allocates and initialises the Tweet "view".
    [tweeter setInitialText:tweet]; // Sets the text of the tweet to be that of the   NSString *tweet
    [self presentModalViewController:tweeter animated:YES]; //Present the Tweet view to   the user.
}
}

- (void)viewDidLoad
{
[super viewDidLoad];



    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:  (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}



@end

I hope you can help me guys!

Upvotes: 0

Views: 257

Answers (2)

Guru
Guru

Reputation: 5363

You can change your root view controller simply by doing this.

 Over *screen = [[Over alloc] initWithNibName:@"Over" bundle:nil];
[[AppDelegate application].window.rootViewController = over;

Upvotes: 2

chewy
chewy

Reputation: 8267

change this

-(IBAction)Over {

Over *screen = [[Over alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:screen animated:YES];


}

to this

-(IBAction)OverView {

Over *screen = [[Over alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:screen animated:YES];


}

and connect the button action to "OverView" opposing to Over

Upvotes: 0

Related Questions