我有一個包含pdf的uiviewcontroller。在uitabbarcontroller中繪製pdfpage
pdf是在viewcontroller的上下文中繪製的,部分由導航欄頂部和底部的tabbar(這是我想要的)覆蓋。
我想用雙擊來隱藏兩個酒吧,並可視化完整的pdf頁面。
問題是,PDF的底部沒有繪製,當我隱藏底部tabBar這個事實變得明顯(頂部的導航欄隱藏效果很好)。
我的問題是:底部欄隱藏後,如何在「完整」上下文中繪製pdf?
(我已經嘗試使用setNeedsDisplay
迫使重繪,但背景仍是吧躲在後同)
以下是平的PDF頁面的代碼:
-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx
{
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(ctx, self.bounds);
CGContextTranslateCTM(ctx, 0.0, self.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(pdfPage,kCGPDFMediaBox,self.bounds, 0, true));
CGContextDrawPDFPage(ctx, pdfPage);
}
的代碼,在itializes條(在AppDelegate中):
tabBarController = [[UITabBarController alloc] init];
MagazineViewController *magazineViewController = [[MagazineViewController alloc] init];
NewsTableViewController *newsViewController = [[NewsTableViewController alloc] init];
VideoViewController *videoViewController = [[VideoViewController alloc] init];
UINavigationController *magazineNavigationController = [[UINavigationController alloc] initWithRootViewController:magazineViewController];
UINavigationController *newsNavigationController = [[UINavigationController alloc] initWithRootViewController:newsViewController];
UINavigationController *videoNavigationController = [[UINavigationController alloc] initWithRootViewController:videoViewController];
magazineNavigationController.navigationBar.tintColor = [UIColor blackColor];
newsNavigationController.navigationBar.tintColor = [UIColor blackColor];
videoNavigationController.navigationBar.tintColor = [UIColor blackColor];
NSArray *tabsArray = [NSArray arrayWithObjects:magazineNavigationController, newsNavigationController, videoNavigationController, nil];
tabBarController.viewControllers = tabsArray;
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
這隱藏了吧代碼:
for (UINavigationController *controller in tabBarController.viewControllers) {
if(controller.navigationBar.topItem.title == @"Magazine") {
[controller setNavigationBarHidden:(!controller.navigationBar.hidden) animated:YES];
tabBarController.tabBar.hidden = !tabBarController.tabBar.hidden;
[self setNeedsDisplay];
return;
}
}
感謝
不錯的功能,但它不會透露在這種情況下很多。 – Brandon 2010-11-17 18:30:43
在我看來,dunders dv – 2010-11-17 21:58:01
rect的大小是正確的(320 x 460),但pdf仍然被裁剪。我沒有配置任何CALayer,但現在我試圖繪製ovverriding - (void)drawRect:(CGRect)r但結果是一樣的 – Giovanni 2010-11-18 10:32:49