iPad: Launch MainWindow.xib's primary view without using InterfaceBuilder confi - xcode

I get really confused using InterfaceBuilder to setup the main window xib file's primary controller view. Is there a good example or simple way to launch the ViewController I want to show by default in the Application Delegate instead of setting it up in InterfaceBuilder's MainWindow.xib file?

you can show your view by code as
FirstViewController *fvc = [[FirstViewController alloc] init];
[window addSubView:fvc];

Related

performSegueWithIdentifier opens a new window in OS X

I am working on OS X application using Storyboard.
I have 2 view controllers LaunchViewController and MainViewController. WindowController has LaunchViewController as window content. LaunchViewController does some checks and then segues to MainViewController. I would expect to show MainViewController in first Window but instead I see 2 windows one showing LaunchViewController and other using MainViewController.
[self performSegueWithIdentifier:kSegueToContentView sender:self];
Is this expected behaviour? Should I use ContainerView instead of calling performSegue?
I advise using a custom segue in order to avoid opening new view controllers in a new window.
This Code example may help you...

xcode 4.5.2 Can't make tabbared application

I have xcode 4.5.2. I've tried for a whole day but i couldn't manage to find an appropriate tutorial or sample to create a tab bar application
If i create a tabbed application, i don't know how to add tabs into controller.
If i create an empty application, i can not start it with tab bar controller on window.
I created a xib file. Make it the main source interface source in targets. Add a window and a tabbarcontroller there and link them with the outlets of the appDelegate.
In appDelegate.m in the didFinishLaunchingWithOptions i add the following code
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window addSubview:self.tabbarController.view];
[self.window makeKeyAndVisible];
and nothing helps.
What's the matter?
How can I do that?
Look at this tutorial may help you ,
Creating a Tab Bar Application Using Storyboards.

Downgrading from Storyboard to XIB

So I understand that I can not use storyboard on anything less then 5.0. I have finished my App using storyboard only so am very basic to code.
I am going to re-create my app using XIB, I will create a new XIB file for each of my storyboards.
Want I would like help with is the code I need to cross-fade between each XIB. There will a button linking each XIB.
What do I need to add to ViewController.h and where do I put the code into ViewController.m
Thanks a lot for your help.
Bryce
This is what I use.
- (IBAction)changeViews:(id)sender
{
ModalViewControllerTwo *modalViewControllerTwo = [[ModalViewControllerTwo alloc] init];
modalViewControllerTwo.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[rootViewController presentModalViewController:modalViewControllerTwo animated:YES];
}

How does window management work in Mac development for MenuBar apps?

I'll preface this by saying this is my first Mac application, though I've been building iOs apps for some time.
I've got a menu bar app (system tray app) by which I mean I've got this.
I now want to show an NSWindow I've created in Interface Builder so I've created a class that's derived from NSWindow. Made my class the Window's delegate and from the App Delegate I do this:
MyClass *myClass = [[MyClass alloc] init];
[myClass display];
[myClass center];
[NSApp activateIgnoringOtherApps:YES];
[viewer makeKeyAndOrderFront:nil];
This seems to show a window without the standard window buttons (minimise, maximise, close) rather than the window I've defined.
Is this the right way to be showing windows? and how should the Window be defined so it shows my designed interface?
In Windows Forms programming this would be:
Form myForm = new Form();
myForm.Show();
You rarely need to subclass NSWindow unless you want to override a window's behavior. A more typical usage scenario would be to use an instance of NSWindowController or a subclass of NSWindowController to manage the window, by making that class the File's Owner in Interface Builder. Once this is done, to grab an instance of the window use:
NSWindowController *wc = [[NSWindowController alloc] initWithWindowNibName:#"NIBNAMEHERE"];
[wc showWindow:nil];
Another alternative in your app would be to add an NSWindow IBOutlet to your app delegate, and load the window in your app delegate with:
[NSBundle loadNibNamed:#"NIBFILENAME" owner:self];
[_window makeKeyAndOrderFront];

Changing app to use a Tab Bar controller

I'm creating my first iPhone application (using XCode 4), and I initially created the project using the Navigation based application template. I've since decided that I want the UI to have a Tab Bar down the bottom with a Navigation Bar up the top, but am having difficulty changing my app to do that.
I added a new window to my app, and called it TabWindow.xib. I opened this up in Interface Builder and added a Tab Bar Controller. I then added an outlet property for the controller into AppDelegate.h as follows:-
#property (nonatomic, retain) IBOutlet UITabBarController *tabController;
This was synthesized in AppDelegate.m with the following:-
#synthesize tabController=_tabController;
I then changed the code in applicationDidFinishLaunchingWithOptions to the following (to switch out the old view controller with my new one):-
//self.window.rootViewController = self.navigationController;
self.window.rootViewController = self.tabController;
When I run the application, instead of seeing the Tab Bar view as expected, I see an empty window. I suspect I need to (at the very least) connect to the tabController outlet I created above, but I can't figure out how to do this. And is there anything else I need to do to get this to work?
You need to add the connection to the app delegate in interface builder. To do this, add an "Object" from the Object library and change its class to your app delegate. Then add the connections in the connections inspector.
Also, in your applications info plist file, you might have to set "Main nib file base name" to the new xib name.

Resources