[Cocoa] How to switch views in a "toolbar" application

Hi everybody.
I have a window with a toolbar with 3 buttons. Each of this button represent a view. I'm having problems switching view.
I have 3 different NSViewController (one for each view) and a NSWindowController that manages only the switching.
With the current code the switch works, but the animation is terrible!
I've already took a look to the example BasicCocoaAnimations, but if I use that code, my views can't keep the origin, and also the size change every time a switch the view.
This is my code:
[code]
- (IBAction)showTenants:(id)sender {   
    if (currentViewController && currentViewController == tenantsViewController)
        return;
    if (!tenantsViewController) {
        tenantsViewController = [[TenantsViewController alloc] init];
        tenantsViewController.managedObjectContext = self.managedObjectContext;
    [NSAnimationContext beginGrouping];
    if (currentViewController) {
        [[[self.window contentView] animator] replaceSubview:currentViewController.view with:tenantsViewController.view];
    else {
        [[[self.window contentView] animator] addSubview:tenantsViewController.view];
    [self.window setFrame:[self newFrameForNewContentFrame:tenantsViewController.defaultFrame]
                  display:YES animate:YES];
    [tenantsViewController.view setFrame:[tenantsViewController defaultFrame]];
    [NSAnimationContext endGrouping];
    currentViewController = tenantsViewController;
- (NSRect)newFrameForNewContentFrame:(NSRect)contentFrame {
    NSRect newFrameRect = [self.window frameRectForContentRect:contentFrame];
    NSRect oldFrameRect = [self.window frame];
    NSSize newSize = newFrameRect.size;
    NSSize oldSize = oldFrameRect.size;
    NSRect frame = [self.window frame];
    frame.size = newSize;
    frame.origin.y -= (newSize.height - oldSize.height);
    return frame;
[/code]
The defaultFrame method simply returns a NSRect with the statical size and origin (retrieved from IB)... this is the only way I managed to fix the size problem...
Any help in improving the code?
Thanks
Francesco

Nobody?

Similar Messages

  • How to switch views in multiclip editing?

    Sorry, newbie error, I'm sure. I've created a multi clip, very simple with 2 videos. How do I switch between them? I've got the buttons on the timeline and the viewer. All they do is beep when I click on anything. I loaded multiclip keyboard layout, and see that shift-2 should switch to video2, etc. It does nothing. There's a menu item as well. It does nothing. I've tried while the video is stopped, while it's running, nothing. What I am doing wrong?

    Sorry, found the answer, tho I don't understand it. The sync menu in the browser was set to audio. Setting it to audio+video fixed the problem.

  • How do i view this type of application?

    I copied this example code from a book, but i dont know how to view it as a running program:
    public class PondVolume {
         public static void main(String[] args) {
              if (args.length != 3) {
              System.out.println("Usage: java Pondvolume Length Width Depth");
              System.exit(0);
         float length = Float.valueOf(args[0]).floatValue();
         float width = Float.valueOf(args[1]).floatValue();
         float depth = Float.valueOf(args[2]).floatValue();
         float volume = length * width * depth * 7.5f;
         System.out.println("Pond length = " + length + " feet");
         System.out.println("Pond width = " + width + " feet");
         System.out.println("Pond depth = " + depth + " feet");
         System.out.println("Pond volume = " + volume + " gallons");
    is there anything wrong with this code, and how should i run it?
    Thanks

    At the command prompt you type "javac PondVolume.java" to compile and then to run type "java PondVolume x y z" where x is the length of your pond, y is the width, and z is the depth. The program will print the results to the screen.
    -S-

  • How do I view or open an application/applefile that somebody has sent to me,

    Somebody who uses an Apple computer has scanned and sent me a document (Applefile) to my email as an attachment.
    When I want to open it, a box opens and Firefox asks me
    What should Firefox do with this file?
    Open with ¨Browse ¨,
    or Save file.
    I want to open this file, but do not know with which application I am suppose to open it,
    nor do I know how to find such an application.
    I use Open Office, and normally Firefox chooses for me how to open something, but sadly not this time.
    So, I do not know how to open this file.
    Who can help me?

    See if the answer in this thread helps you. <br />
    http://www.pcreview.co.uk/forums/thread-3382267.php
    The easiest thing to do might be to ask the sender to resend that attachment using a different email program, or by web mail.

  • How can I add the Language Toolbar to my English version of Firefox? I want to be able to switch to Japanese language for certain websites and when typing e-mails.

    How can I add the Language Toolbar to my English version of Firefox? I want to be able to switch to Japanese language for certain websites and when typing e-mails.
    There should be something that allows me to switch back and foth between Japanese and English...or is that in Windows XP and not in the browser?

    See:
    * http://windows.microsoft.com/en-US/windows7/The-Language-bar-overview The Language bar (overview)
    * http://support.microsoft.com/kb/258824 - How to change your keyboard layout

  • How to switch which program to view photos with?

    I have a Droid Razr.  From the camera program when I click on photo in the upper right hand corner to view my gallery, it appears the gallery is opening with google photos instead of gallery.  The google photos app dims the back lighting on the photos making it difficult to view.  I would like to switch back to viewing photos using gallery, but can't figure out how to switch back to that program by default.

    I spent several hours on the phone with VZW last night for this very issue. They had no idea how to fix it.
    Ann154 is correct. However, I have a Galaxy Nexus, and for me, I went to Settings>Apps and cleared the defaults for the
    Google+ app and that is what resolved the issue for me. Just trying to help get the word out for anyone else who may be as
    frustrated as I was.

  • How do I switch views on my laptop to see only one page not three

    how do I do this, don't how I switched from one page to three

    You can re-download your apps and ibooks purchases via your purchase history in iTunes on your computer (assuming that it's version 10.3+), and if you are in the USA then you can also re-download music I think - more info here http://support.apple.com/kb/HT2519
    For music that you ripped from CDs or bought from a source other than iTunes then, assuming that you made/maintained one, you can copy them from your backup - and backups are relatively easy to maintain, so there is no reason not to have one (especially as content is occasionally removed from iTunes so isn't always available for re-download). Otherwise there may be third-party programs that can copy them off the iPad, but you can't do it via iTunes - this post from a year ago was about iPod/iPhone to computer utilities but some might work with the iPad : https://discussions.apple.com/message/11646661?messageID=11646661&#11646661 .
    If you've got content in other apps that you want to copy back to your computer then you might be able to do via the file sharing section at the bottom of the iPad's apps tab in iTunes, or they might have wifi transfer capability.

  • How to show picture in switch view ( Creative ZEN Vision:

    Hi
    I have Creative ZEN Vision:M, I try to use music folder of "Switch view" to show picture, right now only one folder is showing picture, the other folders are not able to display pictures, am I need to doing some kind of setup?
    Thanks.

    Just wanted to mention - I bought the IR Remote thinking to make the player useful without navigation keys. Now I feel like I wasted more money instead of shifting to some other player by some other company with better customer service.

  • How do I disable the MP3Tube tool bar when Firefox opens? I have already unchecked it in the views menu, under toolbar. It disappears when I do that, but comes back every time I reopen Firefox.

    When I log on to Firefox, the home page displays a tool bar called "MP3 Tube" powered by Yahoo. I would like to remove that toolbar permanently from my start up page. I have tried to uncheck it in the View menu under Toolbars, but it reappears every time I log off and log back on to Firefox.

    You're welcome

  • How to switch focus in Mail.app?

    Hello!
    I am trying to use Mail.app only with the keyboard.
    However one last thing keeps me using the MagicTrackpad: I was not able to discover how to switch the focus from one folder of the folder list on the left side to the mails within this folder (in the middle panel - using the 3-panel-view).
    Do you have an idea how to do this?
    Thank you!
    Kind regards,
    Vlad

    Hi, Jeffrey!
    Thanks for your reply!
    In the linked article you can find:
    "You can use the tab key to switch between the three areas of Mail.app’s interface — (1) the Mailbox Viewer, (2) The Message List Viewer, the (3) Preview Pane and the search field in the Toolbar:"
    This is no longer true for me (not even in the classic design!), running Version 6.2 (1499) from Mail.app with 10.8.2: I can not switch between this areas using the tab key!
    Do you?
    Kind regards,
    Vlad

  • How can I view all my apple map pushpin Points of Intrest and pictures at once?

    Been trying to find a way to view all my Apple Maps Points of Interest pushpins all at once on the map screen.  As I drive along routing, or when I zoom in and out of map areas.  Saved bookmarks shows a long list, but I can't figure out how to just view all the pushpins on the map, so I can access my favorite locations and notes as I drive or plan a trip. 
    Maybe create a map pushpin folder to save only pictures related to the saved map bookmarks.  And save on phone or skydrive?  I still just go by memory.  But the list, notes and scenes are getting really numerous.  RV campsites, fishing, biking, skiing, services, phone signal, shopping, wifi, laundry, jobs, pictures, and much more. 
    I have an old HP mini that I like and use with my iphone 4.  Have no interest or extra money to be upgrading my devices every time the software/bloatware updates overload otherwise perfectly good phones and laptops.  Hope to be able to share with others how to have their phones and computers work for them, instead of the other way around. 
    Might stay with iPhone and even buy an ipad if they become more univerally compatible, or switch to all windows devices.  Not too happy with PCs bloatware programming these days either.  My old windows 98 laptop runs some really powerful programs.  Wonder how many people would buy Jeeps and such vehicles, if they could not easily drive them on regular city streets or highways?
    first posting in online support community in 15 years.  Home powered by Solar these days.  Can even park next to a street light and charge batteries.
    Thanks for reading and any useful info.  will try not to lose my login info

    Been trying to find a way to view all my Apple Maps Points of Interest pushpins all at once on the map screen.  As I drive along routing, or when I zoom in and out of map areas.  Saved bookmarks shows a long list, but I can't figure out how to just view all the pushpins on the map, so I can access my favorite locations and notes as I drive or plan a trip. 
    Maybe create a map pushpin folder to save only pictures related to the saved map bookmarks.  And save on phone or skydrive?  I still just go by memory.  But the list, notes and scenes are getting really numerous.  RV campsites, fishing, biking, skiing, services, phone signal, shopping, wifi, laundry, jobs, pictures, and much more. 
    I have an old HP mini that I like and use with my iphone 4.  Have no interest or extra money to be upgrading my devices every time the software/bloatware updates overload otherwise perfectly good phones and laptops.  Hope to be able to share with others how to have their phones and computers work for them, instead of the other way around. 
    Might stay with iPhone and even buy an ipad if they become more univerally compatible, or switch to all windows devices.  Not too happy with PCs bloatware programming these days either.  My old windows 98 laptop runs some really powerful programs.  Wonder how many people would buy Jeeps and such vehicles, if they could not easily drive them on regular city streets or highways?
    first posting in online support community in 15 years.  Home powered by Solar these days.  Can even park next to a street light and charge batteries.
    Thanks for reading and any useful info.  will try not to lose my login info

  • How do I remove an unwanted toolbar?  I added a radio station to my ibook and it set up its own toolbar so when I go to Safari I have to use it.  It involves using Bing for everything as well.  It's very annoying and I want to remove it.

    How do I remove an unwanted toolbar?  I added a radio station to my ibook and it set up its own toolbar so when I go to Safari I have to use it.  It involves using Bing for everything as well.  It's very annoying and I want to remove it.  I can't just type in a URL and have it go to the site.  It takes me to all of Bing's choices.  Also, when it anticipates what I'm typing (incorrectly) and I have to delete it's guesses all the time.  Can anyone help?

    Have you looked at Safari's menu bar > view> toolbars to see if it can be unchecked from there,also see if there is a button to collapse the toolbar on the bar itself.

  • How can I just disable "navigation toolbar" completely for the App Tabs? I don't want to disable this for other normal tabs.

    How can I just disable "navigation toolbar" completely for the App Tabs? I don't want to disable this for other normal tabs. This is important as otherwise while I am in the app tab, i mistakenly start browsing from that tab and meaning of the app tab is completely lost...

    How can I view my full billing history for the app and music stores without iTunes installed?
    No.
    If my account has been compromised
    If you even think this may have happened, immediately change your password.
    See this -> Apple ID: Changing your password

  • HT2500 CANNOT VIEW NEW MESSAGE TOOLBAR

    How can I get the new message toolbar. I am using mac mini with OS X version 10.7.03 and mail version 5.2 (1257).
    When I write a new email I have to open the address book in the dock to find my contacts. Makes emailing to several people very slow. I know how to set up groups and am able to do that. I want the option to go through my addresses the way I do when using aol.com to send messages.

    Thanks for the help! I opened a new message and clicked on view in the toolbar, clicked on customize toolbar, and then dragged the address icon up to the new message toolbar. Works!

  • How can I show the bookmarks toolbar in Firefox 6 all the time?

    The bookmarks toolbar is hidden by default in Firefox 6, and "view bookmarks toolbar" will only show it until a link is clicked or the tab is changed. How can I display the bookmarks toolbar in Firefox 6 all the time?

    On your toolbar area right click an empty space and open Customize.
    Then drag the bookmark icon up to your toolbar area and drop.

Maybe you are looking for