2012-12-31 64 views

回答

3

使用

-(void)didTap 
{ 
[self.navigationController setNavigationBarHidden:YES animated:YES]; 
//remove your tool bar from superview 
[toolbar removeFromSuperview]; 
//code to add ur UIWebView 

} 
3

要隱藏頂部導航欄,請使用navigationBarHidden屬性或setNavigationBarHidden:animated:方法(如果需要動畫)。同樣,對底部工具欄使用toolbarHidden屬性或setToolbarHidden:animated:方法。這些是UINavigationController的一部分。

如果要同時爲工具欄隱藏和UIWebView展開設置動畫,請將UIWebView的大小更改包裝爲UIView animateWithDuration...方法。

添加您選擇的手勢識別器。對於滑動,請創建一個實例UISwipeGestureRecognizer並將其添加到您的視圖。像這樣的事情在你的viewDidLoad方法:

UISwipeGestureRecognizer *swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe)]; 
[self.view addGestureRecognizer:swipeGestureRecognizer]; 

而且刷卡處理程序是這樣的:

-(void)handleSwipe{ 
    if (self.navigationController.navigationBarHidden) { 
     [self.navigationController setNavigationBarHidden:NO animated:YES]; 
     [self.navigationController setToolbarHidden:NO animated:YES]; 
     [UIView animateWithDuration:0.3 animations:^{ 
      self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y, self.webView.frame.size.width, self.webView.frame.size.height - 88); 
     }]; 
    } else { 
     [self.navigationController setNavigationBarHidden:YES animated:YES]; 
     [self.navigationController setToolbarHidden:YES animated:YES]; 
     [UIView animateWithDuration:0.3 animations:^{ 
      self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y, self.webView.frame.size.width, self.webView.frame.size.height + 88); 
     }]; 
    } 
}