/ / NSTextView в NSAlert няма ленти за превъртане - object-c, какао

NSTextView в NSAlert няма скролерни ленти - цел-c, какао

Аз се опитвам да добавя NSTextView в NSAlert, така че потребителят да може да въведе в него. Въпреки това, лентите за превъртане никога не се появяват, без значение колко потребител въвежда.

Ето кода, който използвам, и екранна снимка на диалоговия прозорец, който се показва:

NSAlert *alert = [NSAlert alertWithMessageText:@"Enter stuff here:"
defaultButton:@"OK"
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@""];



NSTextView *textView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, 200, 50)];
[alert setAccessoryView:textView];
[alert runModal];

Снимка на липсата на ленти за превъртане

Отговори:

1 за отговор № 1

Трябва да поставите NSTextView в NSScrollView.

Apple описва процеса в този документ.

Основният код от там е:

NSScrollView *scrollview = [[NSScrollView alloc]
initWithFrame:[[theWindow contentView] frame]];
NSSize contentSize = [scrollview contentSize];

[scrollview setBorderType:NSNoBorder];
[scrollview setHasVerticalScroller:YES];
[scrollview setHasHorizontalScroller:NO];
[scrollview setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
theTextView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0,
contentSize.width, contentSize.height)];
[theTextView setMinSize:NSMakeSize(0.0, contentSize.height)];
[theTextView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[theTextView setVerticallyResizable:YES];
[theTextView setHorizontallyResizable:NO];
[theTextView setAutoresizingMask:NSViewWidthSizable];

[[theTextView textContainer]
setContainerSize:NSMakeSize(contentSize.width, FLT_MAX)];
[[theTextView textContainer] setWidthTracksTextView:YES];
[scrollview setDocumentView:theTextView];
[theWindow setContentView:scrollview];
[theWindow makeKeyAndOrderFront:nil];
[theWindow makeFirstResponder:theTextView];
[[theTextView enclosingScrollView] setHasHorizontalScroller:YES];
[theTextView setHorizontallyResizable:YES];
[theTextView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[[theTextView textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[[theTextView textContainer] setWidthTracksTextView:NO];

0 за отговор № 2

В xib вътрешността на атрибутите инспекторът позволява само вертикалните и хоризонталните скролери.