• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
why doesn't my scrollview scroll ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

why doesn't my scrollview scroll ...


  • Subject: why doesn't my scrollview scroll ...
  • From: Martin Redington <email@hidden>
  • Date: Fri, 2 Jun 2006 14:30:05 +0100


I followed the recipe at:

http://developer.apple.com/documentation/Cocoa/Conceptual/TextUILayer/ Tasks/TextInScrollView.html

as below, but my scroll view refuses to scroll (the scroll bar never gets activated), although I can move up and down in the document fine.

#import "TestScrollViewController.h"

#define DEFAULT_TEXTAREA_HEIGHT 66.0f
#define DEFAULT_TEXTAREA_WIDTH 200.0f

@implementation TestScrollViewController


- (NSView *) textArea{
float textAreaFrameRectWidth = DEFAULT_TEXTAREA_WIDTH;
float textAreaFrameRectHeight = DEFAULT_TEXTAREA_HEIGHT;
NSRect textAreaFrameRect = NSMakeRect(0.0f, 0.0f, textAreaFrameRectWidth, textAreaFrameRectHeight);


NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame:textAreaFrameRect];

[scrollView setBorderType:NSBezelBorder];
[scrollView setHasHorizontalScroller:NO];
[scrollView setHasVerticalScroller:YES];
[scrollView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];


// doesn't seem to make any difference.
//    [[scrollView contentView] setAutoresizesSubviews:YES];

    NSSize scrollViewContentSize = [scrollView contentSize];

NSTextView *textArea = [[NSTextView alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, scrollViewContentSize.width, scrollViewContentSize.height)];
[textArea setMinSize:NSMakeSize(scrollViewContentSize.width, scrollViewContentSize.height)];
[textArea setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[textArea setVerticallyResizable:YES];
[textArea setHorizontallyResizable:NO];


[textArea setAutoresizingMask:NSViewWidthSizable];
[[textArea textContainer] setContainerSize: NSMakeSize (scrollViewContentSize.width, FLT_MAX)];
[[textArea textContainer] setWidthTracksTextView: YES];


    [scrollView setDocumentView:textArea];

    return scrollView;
}

////////////////////////////////////////////////

- (void) awakeFromNib
{
    NSView *view = [self viewForDictionary:nil];
    // _window is an IBOutlet to the main window
    [[_window contentView] addSubview:[self textArea]];
}


@end

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: why doesn't my scrollview scroll ...
      • From: Lon Giese <email@hidden>
  • Prev by Date: Re: Newbie error
  • Next by Date: getting things out of and putting thins in the doc
  • Previous by thread: Crazy NSTreeController
  • Next by thread: Re: why doesn't my scrollview scroll ...
  • Index(es):
    • Date
    • Thread