本文介绍了在UIImagePickerController中隐藏快门的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPhone应用程式中设计了相机视图的光圈快门动画。

I have designed an iris shutter animation for a camera view in an iPhone app.

不幸的是,当视图出现时,看起来不可能隐藏Apple的快门,我隐藏了相机控件,并创建了一个自定义的cameraOverlayView。

Unfortunately, it seems impossible to hide Apple's shutter when the view appears, even if I hide the camera controls and create a custom cameraOverlayView.

我已经通过在视图出现时使快门在正常快门上动画,使用viewWillAppear和UIImagePickerController的viewDidAppear方法。但是,我不能让快门被隐藏在我的快门下第一次通过。当应用程序启动时,它显示相机视图,并且原始快门可见。在cameraController的所有后续视图,我的解决方法工作。有任何建议吗?

I have gotten around this by animating my shutter on top of the normal shutter when the view appears, using the viewWillAppear and viewDidAppear methods of UIImagePickerController. However, I can't get the shutter to be hidden under my shutter the first time through. When the app launches, it shows a camera view, and the original shutter is visible. On all subsequent views of the cameraController, my workaround works. Any suggestions?

这是我的代码。这是来自我的应用程式委托:

Here's my code. This is from my app delegate:

- (void)applicationDidFinishLaunching:(UIApplication *)application {   

  cameraController = [[CameraController alloc] initWithMode:@"camera"];
  [window addSubview:cameraController.view];

}

这是从我的UIImagePickerController子类:

And this is from my UIImagePickerController subclass:

- (void) viewWillAppear:(BOOL)animated {

  if (self.sourceType != UIImagePickerControllerSourceTypePhotoLibrary || simulatorView) {
    [self addShutter];
    [shutter close];
  }   
  [super viewWillAppear:animated];

}


- (void) viewDidAppear:(BOOL)animated {

  if (self.sourceType != UIImagePickerControllerSourceTypePhotoLibrary || simulatorView) {
    [shutter openShutter:.5f];
  }
  [super viewDidAppear:animated];

}


推荐答案

文档说,不支持子类化UIImagePickerController,因此它可能在某些情况下工作,但不是安全。不确定是否会被应用商店拒绝。 (可能取决于他们的静态代码验证工具是多么挑剔。)

Note that the docs say that subclassing UIImagePickerController isn't supported, so it may work in some cases but isn't "safe". Not sure if it would get rejected by the app store. (Probably depends on how picky their static code verification tool is.)

我真的没有一个很好的答案,但你可能尝试1)迭代的子视图选择器的主视图,看看是否可以识别用于动画快门的任何东西,然后摇晃它,以便它不会显示,或2)对于初始动画,只显示在另一个不透明的初始图像选择器主视图黑色视图。不确定用户指定的重叠式视图是否会工作,但您可以在没有子类化的情况下执行这些操作。

I don't really have a good answer, but you might try either 1) iterating over the subviews of the picker's main view to see if you can identify whatever is being used to animate the shutter, then mangle it so that it won't display, or 2) for the initial animation, just show the initial image picker main view under another opaque black view. Not sure if the user-specified overlay view would work for that or not, but you might be able to do those without subclassing.

搜索未记录的子视图是另一件事理论上是不安全的,因为谁知道实现在未来可能会改变。

Searching for undocumented subviews is another thing that's theoretically unsafe though since who knows how the implementation might change in the future.

这篇关于在UIImagePickerController中隐藏快门的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 19:49