如何通过单击标签栏应用程序中的标签打开相机,我还想自定义该相机控制器?我见过很多这样的应用程序,它们也有额外的功能,比如instagram这也像这个pinterest一样使用这是另一个picplz我用谷歌搜索了一些链接,但我没有得到完美的结果我试图通过打开相机- (void)viewWillAppear:(BOOL)animated
但它并不完美,任何人都可以指导我创建像上面一些应用程序一样的相机视图吗?
嘿,有人有答案吗?
试试这个代码片段。
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];
- (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];
}