1

我有我的应用程序,它支持 iOS 5.1 和更新版本。但是,我想在低于 iOS 6.x 时隐藏相机按钮。我怎样才能做到这一点?这是我添加相机按钮的方法:

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
if ([viewController isKindOfClass:[ATWebViewController class]]) {
    NSURL *url = nil;
    if (viewController.tabBarItem.tag == 0) {
        url = [NSURL URLWithString:@"http://----.de"];
    }
    else if (viewController.tabBarItem.tag == 1) {
        url = [NSURL URLWithString:@"http://----.de"];
    }

// 如果 viewController.tabBarItem.tag==0 ATWebViewController *webViewController = [[ATWebViewController alloc] initWithNibName:nil bundle:nil URL:url ];

    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;

}

4

1 回答 1

1

通常最好通过检查类或方法的存在来检查特定功能。但在这种情况下,没有合适的 API 检查针对UIWebView.

一种解决方案是:

if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"5"]) {
    // iOS 5.x
} else {
    // not iOS 5.x
}
于 2013-05-11T02:35:17.900 回答