故事板 UIImagePicker 覆盖 UIButton 不会关闭预览 [英] Storyboard UIImagePicker overlay UIButton does not dismiss preview

查看:27
本文介绍了故事板 UIImagePicker 覆盖 UIButton 不会关闭预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新 2

viewDidAppear 执行两次,一次之前和一次之后,覆盖按钮被触摸.解决方法是向 viewDidAppear 添加一个条件,它会将控制权返回给调用类?如果是这样,我将不胜感激建议.或者,也许 viewDidAppear 执行两次这一事实暗示了另一种修复方法?

viewDidAppear is executed twice, once before and once after, the overlay button is touched. Would a fix be to add a conditional to viewDidAppear which would return control to the calling class? If so, I would appreciated suggestions. Or maybe the very fact that viewDidAppear execute twice suggests another approach to a fix?

更新 2

更新 1

也许问题是我对 viewDidAppearviewDidLoad 的使用如下所示.有谁可以帮忙吗?

Maybe the problem is my usage of viewDidAppear and viewDidLoad shown below. Can anyone help, please?

- (void)viewDidAppear:(BOOL)animated
{

    self.overlayViewController = [[BSsetupOverlayViewController alloc] initWithNibName:@"BSsetupOverlayViewController" bundle:nil] ;

    // as a delegate we will be notified when pictures are taken and when to dismiss the image picker
    self.overlayViewController.delegate = self;


    [self showImagePicker:UIImagePickerControllerSourceTypeCamera];

}


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

更新 1

更新 0

也许我不清楚不起作用的版本和起作用的版本之间的区别在于,在不起作用的版本中使用了 Storyboard.为什么 done 按钮可以在没有 Storyboard 的情况下工作,而不是,即使只有一个笔尖与覆盖层有关?

Perhaps I was not clear that the difference between the version that does not work and the one that does is that Storyboard is used in the one that does not work. Why would a done button work without Storyboard, but not with, even though only a nib is involved with the overlay?

更新 0

此处的 UIButton 能够关闭相机预览,但在我的实际应用中,点击UIButton 只是暂时关闭预览和覆盖屏幕.预览立即返回.我认为问题在于我实现 UIImagePicker 的委托的方式,但我可能错了.

The UIButton here was able to dismiss the camera preview, but in my actual app, tapping the UIButton only temporarily dismisses the preview and overlay screen. Immediately the preview returns. I think the problem is with the way I am implementing the delegate to the UIImagePicker, but I may be wrong.

我在这里创建了setup.zip,其中包含一个具有不良行为的示例项目.

I have created setup.zip here which contains a sample project with the undesirable behavior.

推荐答案

I将此问题带到北亚特兰大 iOS 聚会 并建议使用条件条款可能会解决问题,正如我在问题的更新 2 中提到的.Meetup 的创始人 Kurt Niemi 通过编辑 BSsetupViewController 类迅速展示了如何做到这一点.

I took this question to the North Atlanta iOS Meetup and suggested that a conditional clause might fix the problem, as I mentioned in update 2 of the question. The founder of the Meetup, Kurt Niemi, quickly showed how to do so by editing the BSsetupViewController class.

首先,他向界面添加了一个布尔属性.

First he added a Boolean property to the interface.

@property (nonatomic, assign) BOOL alreadyDisplayed;

其次,他在 viewDidAppear 方法中添加了一个子句.

Second he added a clause to the viewDidAppear method.

if (self.alreadyDisplayed)
{
    self.alreadyDisplayed = FALSE;
    [self dismissViewControllerAnimated:NO completion:nil];
    return;

}

self.alreadyDisplayed = TRUE;

最后他在 viewDidLoad 方法中添加了一个稍微不必要的子句.

And last he added a slight unnecessary clause to the viewDidLoad method.

self.alreadyDisplayed = FALSE;

我仍然希望这些步骤是不必要的,但它们似乎有效.

I still wish these steps were unnecessary, but they seem to work.

这篇关于故事板 UIImagePicker 覆盖 UIButton 不会关闭预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆