我已經創建了廈門國際銀行在文件中PDFView
一個NSWindow
,我創建了一個名爲MainController控制器,在那裏,我創建了一個IBAction爲-(IBAction) openFileAction:(id) sender
,它使用的方法設置文檔以PDFview中的控制器構造
-(void) openFile:(NSString *) path{
NSLog(@"Opening File %@",path);
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:path]];
[pdfView setDocument: pdfDoc];
}
我將打開的菜單項鍊接到openFileAction
,並在點擊後PDF文件正確顯示在PDFView中。
我做一個邏輯接收命令行參數
-(MainController *) init{
[super init];
NSArray *myArgs = [[NSProcessInfo processInfo] arguments];
NSLog(@"pdf view %@", pdfView);
if ([myArgs count] >= 2){
[self openFile:[myArgs objectAtIndex:1]];
}
return self;
}
正如你所看到的,我確實在默認的構造函數,並在這方面pdfView爲null,則該文件未打開後的重寫應用程序/主窗口加載。
我的問題是,如何在應用程序加載後在PDFView中打開PDF? UI加載後是否有任何鉤子?