2013-05-11 75 views
1

我在这里有我的应用程序,它支持iOS 5.1和更高版本。但是,如果低于iOS 6.x,我想隐藏相机按钮。我怎样才能做到这一点?这里是我添加Camerabutton:我想在iOS 5.x中隐藏一个按钮,但不是在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:无束:无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; 

}

+0

你为什么要这么做?你有相机需要的一些6.x API吗? – rmaddy 2013-05-11 02:01:14

+0

我们只是实现了一个市场,这是一个webView的相机。仅在iOS 6中支持在webView中上传图片。因此,该按钮在iOS 5.1.x中没有意义 – 2013-05-11 02:10:25

回答

1

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

一个解决办法是要做到:

if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"5"]) { 
    // iOS 5.x 
} else { 
    // not iOS 5.x 
} 
+0

非常感谢您......我知道我必须检查iOS版本,但尝试使用SLComposeViewOfTypeFacebook ..这个更好...... :) – 2013-05-11 09:56:18