2013-05-20 36 views
0

我從UIScrollView創建PDF。如何在轉換後取消隱藏ScrollView PDF應用程序

它工作正常,並創建一個PDF,但問題是,創建PDF後,scrollView從屏幕消失,當我再次加載應用程序,然後再次顯示,所以我認爲由於PDF創建它隱藏任何方式在創建PDF後取消隱藏它。

我使用下面的代碼:

-(void)createPDFfromUIView: (UIView*)aView saveToDocumentsWithFileName: (NSString*)aFilename 
{ 
    NSMutableData *pdfData = [NSMutableData data]; 

    CGRect scrollSize = CGRectMake(1018,76,1010,1600); 

    [scrollView setFrame:CGRectMake(1018,76,1010,1600)]; 

    // Points the pdf converter to the mutable data object and to the UIView to be converted 
    UIGraphicsBeginPDFContextToData(pdfData,scrollView.bounds, nil); 
    UIGraphicsBeginPDFPage(); 
    CGContextRef pdfContext = UIGraphicsGetCurrentContext(); 

    // draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData 
    [aView.layer renderInContext:pdfContext]; 

    // remove PDF rendering context 
    UIGraphicsEndPDFContext(); 

    // Retrieves the document directories from the iOS device 
    NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES); 
    NSString* documentDirectory = [documentDirectories objectAtIndex:0]; 
    NSString* documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename]; 

    // instructs the mutable data object to write its context to a file on disk 
    [pdfData writeToFile:documentDirectoryFilename atomically:YES]; 
    NSLog(@"documentDirectoryFileName: %@",documentDirectoryFilename); 
} 

回答

0

據我所看到的,問題是在下面一行

[scrollView setFrame:CGRectMake(1018,76,1010,1600)]; 

這將使滾動視圖出可見區域的,因爲你的原點X是1018.所以,實際上它並不隱藏,但它在屏幕或可見區域之外。

你真的需要那條線。

+0

因此可能會在createPDF –

+0

的調用方法後添加此行,但爲什麼要設置這樣的奇數幀?任何特殊需求 – Iducool

+0

它來自界面構建器值和橫向模式 –

相關問題