Iphone iOS-如何在UITableView上显示UIImagePicker?
我有一个表格单元格,当选中时,应该允许用户从照片库中选择一个图像或拍摄一个新图像 屏幕结构为:Iphone iOS-如何在UITableView上显示UIImagePicker?,iphone,ios,xcode,Iphone,Ios,Xcode,我有一个表格单元格,当选中时,应该允许用户从照片库中选择一个图像或拍摄一个新图像 屏幕结构为: UITabBar -> UINavigationController -> ParentController -> MyController 在MyController中实现这一点的代码是 - (void)showPhotoMenu { if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerContr
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屏幕(照片库或相机)无法显示的原因
据我所知,这是一个警告,取消按钮将无法访问,因为选项卡栏覆盖了它
有人能告诉我哪里出了问题吗?没有足够的代码可以确定,但是 操作表将您的代码用作委托,并以固定委托方法将控制权返回给您
- (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程序比您有更多的操作表选项,我永远不会出错。首先,
UIActionSheet
的解决方案是错误的,用于显示UIImagePickerController
的代码在哪里?显示如何显示imagePickerController..哦,derp derp derp-我完全忘记添加代理方法了:/这很好用-感谢您的帮助我在我的操作表中看到了所有操作-但底部的“取消”按钮只激活了一半。如果我点击下半部分,选项卡栏会覆盖它,因此它不会响应。如果我点击上半部分,它工作正常