gpt4 book ai didi

iphone - iOS - 如何在 UITableView 上显示 UIImagePicker?

转载 作者:行者123 更新时间:2023-11-29 04:46:31 25 4
gpt4 key购买 nike

我有一个表格单元格,选择该单元格后,应允许用户从照片库中选择图像或拍摄新图像。

屏幕结构为:

UITabBar -> UINavigationController -> ParentController -> MyController

MyController中实现这一点的代码是

- (void)showPhotoMenu
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Take Photo", @"Choose From Library", nil];

[actionSheet showInView:self.view];
} else {
[self choosePhotoFromLibrary];
}
}

点击单元格时,我可以选择从“库”中进行选择或拍照,但此后似乎没有任何反应。日志输出显示

Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].

但我不确定这就是 ImagePicker 屏幕(照片库或相机)无法显示的原因。

据我所知,这是警告取消按钮将无法访问,因为标签栏覆盖了它?

任何人都可以告诉我这里可能出错的地方吗?

最佳答案

没有足够的代码可以肯定,但是

操作表使用您的代码作为委托(delegate),并通过固定的委托(delegate)方法将控制权返回给您

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == actionSheet.firstOtherButtonIndex + 0) {
//code to take photo
} else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) {
//code to take access media
}
}

另一条警告消息 - 您是否在操作表中看到所有选项?

[actionSheet showInView:self.view]; 

还有更多选项,具体取决于您是否有导航栏或选项卡栏,我有一个 iPhone 程序,其操作表选项比您多,但我从未收到错误。

关于iphone - iOS - 如何在 UITableView 上显示 UIImagePicker?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9564675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com