我这里有一个应用程序,它加载一个包含相机按钮的模态视图(WebView)。问题是,当网页还没有完全加载时,我按下相机按钮并关闭它,然后我有一个白屏,分别是网站在加载时被中断。
因此,只要网页正在加载,我就想让相机按钮“处于非活动状态”。我怎样才能做到这一点?这是我的实际代码:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
if ([viewController isKindOfClass:[ATWebViewController class]]) {
NSURL *url = nil;
if (viewController.tabBarItem.tag == 0) {
url = [NSURL URLWithString:@"http://m.bikemarkt.mtb-news.de"];
}
else if (viewController.tabBarItem.tag == 1) {
url = [NSURL URLWithString:@"http://winterpokal.mtb-news.de"];
}
// 如果 viewController.tabBarItem.tag==0 ATWebViewController *webViewController = [[ATWebViewController alloc] initWithNibName:nil bundle:nil URL:url ];
//Check if the device is running iOS 6.x.x and if yes, then show the camera button
if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"5"]) {
UINavigationController *navigationBarController = [[UINavigationController alloc] initWithRootViewController:webViewController];
navigationBarController.navigationBar.tintColor = ATNavigationBarTintColor;
if (viewController.tabBarItem.tag == 0) {
webViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissWebView)];
}
else if (viewController.tabBarItem.tag == 1) {
webViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissWebView)];
}
navigationBarController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:navigationBarController animated:YES];
return NO;
}
// If not iOS 5
else
{ UINavigationController *navigationBarController = [[UINavigationController alloc] initWithRootViewController:webViewController];
navigationBarController.navigationBar.tintColor = ATNavigationBarTintColor;
if (viewController.tabBarItem.tag == 0) {
webViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissWebView)];
webViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(TakePhoto)];
}
else if (viewController.tabBarItem.tag == 1) {
webViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissWebView)];
}
navigationBarController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:navigationBarController animated:YES];
return NO;
}
}
return YES;
}
@结尾
任何帮助将不胜感激...... :)