初めての OSX アプリを作成しています。私のappDelegateには、NSViewControllerのcontentViewを持つウィンドウがあります。この NSViewController には、起動時に表示されるカスタム ビューがあります。NSScrollView を NSViewController のプロパティとして追加し、xib で正しい位置に配置して、ファイルの所有者 (NSViewController) を参照しました。ビューが表示されている場合、scrollView は表示されません。scrollView を含むコードは次のとおりです。
viewController の .h で:
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import "StockData.h"
@interface MasterViewController : NSViewController {
IBOutlet NSScrollView * scrollView1;
}
@property (retain) IBOutlet NSScrollView * scrollView1;
@property (retain) NSView * contents;
@end
viewController の .m で:
#import "MasterViewController.h"
#import <math.h>
#import <Foundation/Foundation.h>
@implementation MasterViewController
@synthesize scrollView1, contents;
- (void) awakeFromNib
{
self.scrollView1 = [[NSScrollView alloc] init];
self.contents = [[NSView alloc] initWithFrame:NSMakeRect(0,0,430,1000)];
[self.view addSubview:scrollView1];
[self.scrollView1 setDocumentView:self.contents];
}
@end
誰かがそれを助けることができれば、それは素晴らしいことです! ありがとう!