【问题标题】:how to open camera by clicking tab in tab bar in iphone sdk?如何通过单击iphone sdk标签栏中的标签打开相机?
【发布时间】:2012-05-15 04:59:02
【问题描述】:

如何通过单击标签栏应用程序中的标签打开相机,我还想自定义该相机控制器?我见过很多这样的应用程序,它们还有额外的功能,比如instagram这也像这样使用pinterest这是另一个picplz我已经用谷歌搜索了一些链接,但我没有得到完美的结果尝试通过- (void)viewWillAppear:(BOOL)animated 打开摄像头,但它无法完美运行,任何人都可以指导我创建像上面某些应用程序那样的摄像头视图吗?

我见过这个苹果example. 用于自定义相机视图我见过this.

嘿,有人有答案吗?

【问题讨论】:

  • 你好!我只是想这样做,但我没有找到任何明确的文档,你最后解决了吗??,谢谢!!!!
  • @TurboManolo 是的,我从我的应用程序要求中得到了解决方案,我必须从AVCaptureSessionManager 制作我自己的相机,这是链接。 github.com/jj0b/AROverlayImageCapture 如果我帮助了你,请投票支持我的问题。

标签: iphone camera uitabbarcontroller uiimagepickercontroller


【解决方案1】:

试试这个代码 sn-p。

UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
picker.delegate = self; 
picker.allowsEditing = YES;
if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])) 
{
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentModalViewController: picker animated:YES]; 
}
else
{
        // Put alert no camer found
}
[picker release];

【讨论】:

  • 嘿,你有没有完美地阅读我的问题,我真正想要的是,当我点击标签栏按钮时,它应该直接打开相机控制器,而不是 UIACtionSheet 请完美阅读我的问题,看看我给出的示例链接。
  • @Hrushikesh:嘿,这家伙试过吗? :P 请在设备上试试这个,即第二代 iPod。(启用相机)。请正确测试代码,然后只对答案投反对票。
  • 我已经尝试过你上面的代码,但是你有没有看到我提供的链接,他们在点击标签栏按钮时直接打开自定义相机请查看这个应用程序,它们是完全免费的。
【解决方案2】:
- (IBAction)buttonTap:(id)sender
{
    UIActionSheet * theActionSheet;

    if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        theActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:NSLocalizedString(@"Choose existing photo", nil) otherButtonTitles:nil, nil, nil];
        self.actionSheet = theActionSheet;
    }
    else
     {
         theActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:NSLocalizedString(@"Take photo", nil) otherButtonTitles:NSLocalizedString(@"Choose existing photo", nil), nil, nil];
         self.actionSheet = theActionSheet;
     }
     self.actionSheet.tag = 100;
     self.actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
     [self.actionSheet showInView:self.view.window];    // show from our table view (pops up in the middle of the table)
     [theActionSheet release];      
}

【讨论】:

  • 嘿,这是您之前给出的答案的相同副本/过去。请避免此类错误
  • @user1395270 嘿,你有没有完美地阅读我的问题我真正想要的是,当我点击标签栏按钮时,它应该直接打开相机控制器而不是 UIACtionSheet 请仔细阅读我的问题,看看我给出的示例链接.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-08
  • 1970-01-01
  • 2021-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-23
相关资源
最近更新 更多