Xcode:在WebView完全加载之前使UIButton处于非活动状态?

时间:2013-05-12 10:11:17

标签: xcode button hide

我这里有一个App,它加载一个包含Camera按钮的ModalView(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;

}

@end

任何帮助都将受到高度赞赏......:)

1 个答案:

答案 0 :(得分:0)

webViewDidFinishLoading:协议

实施UIWebViewDelegate

仅在那里设置按钮拍摄照片,而不是立即拍摄