Resizable webview with fixed minimum size.

Discussion in 'Mac Programming' started by Marimuthu, Nov 21, 2011.

  1. Marimuthu macrumors member

    Joined:
    Oct 18, 2010
    #1
    Hi All,

    I am developing an Web based application where I load an URL onto a webview successfully.

    I derive my webview class from NSWindowController class and register the webview delegates and implement methods in the derived class to receive the various web related notifications. The web page loads as expected and I am able to resize the webview to any size.

    Is it possible to specify a pre-defined minimum size to the Webview such that a user must not be able resize the view below this fixed size ? However should be able to resize the view to any larger view.
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    1. Open the .xib containing your window
    2. Select your window (not the web view in your window)
    3. Show the size inspector
    4. Tick minimum size under Constraints
    5. Enter a minimum width and height in pixels.
     
  3. Marimuthu thread starter macrumors member

    Joined:
    Oct 18, 2010
    #3
    Hi jiminaus,

    Yes. Now it works as expected.

    Thanks a lot.
     
  4. Marimuthu thread starter macrumors member

    Joined:
    Oct 18, 2010
    #4
    Hi All,

    I have observed that when I resize the webview window to some larger window size(from it's initial default fixed size), if I were to exit the application and launch my app again, the resized view is shown.

    Is there a mechanism by which I limit the resizing of the webview only to that application session i.e, If the app is exited and launched again, the webview displayed must be it's initial default size (and not the resized size).
     
  5. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #5
    1. Open the .xib containing your window
    2. Select your window (not the web view in your window)
    3. Show the Attributes Inspector
    4. Untick Restorable under Behavior

    You may have to delete your apps preferences file under ~/Library/Preferences as well.
     
  6. Marimuthu thread starter macrumors member

    Joined:
    Oct 18, 2010
    #6
    Hi jiminaus,

    I am actually loading the webView onto an NSPanel. There too, i was not able to find this "Untick Restorable under Behavior" setting that you are referring to.

    What am I doing wrong here? I have attached the screenshot of Attribute Inspector setting for your kind reference.
     

    Attached Files:

  7. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #7
    Wow, XCode 3. It's been way too long for me to remember XCode 3. Sorry.
     
  8. Marimuthu thread starter macrumors member

    Joined:
    Oct 18, 2010
    #8
    Could you please provide the API equivalent of this setting? I could use the same in my code in awakeForNib.
     

Share This Page