iPhone:相机预览叠加
如何将叠加层 (UIImageView
) 添加到相机预览并 处理这个问题吗?
我之前尝试执行此操作(例如使用 UIImagePickerController 并将图像添加为子视图)失败了。
How do I add an overlay (UIImageView
) to the camera preview and
handle touches on this?
My previous attempts to do this (e.g. use UIImagePickerController
and add the image as a subview) have failed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于您的实现文件:
创建一个 UIView 类并添加此代码
For your implementation file:
Make a UIView class and add this code
您可以直接将
UIImageView
添加为主窗口的子视图,而不是UIImagePicker
,这样效果可能会更好。 只需确保按正确的顺序添加它们,或者在相机启动后致电即可。
如果您想处理
UIImageView
上的触摸,只需将UIImageView
添加为具有透明背景的普通全屏View
的子视图,然后将 that 添加到窗口,并使用可用于处理触摸事件的普通UIViewController
子类。You may be able to add the
UIImageView
as a subview of the main window directly instead of theUIImagePicker
, it may work better. Just make sure to add them in the right order, or callafter the camera is up.
If you want to handle touches on the
UIImageView
you could just add theUIImageView
as a subview of a normal fullscreenView
with a transparent background, and add that to the window instead, with a normalUIViewController
subclass that you can use to handle the touch events.查看相机叠加视图(3.1 及更高版本中提供)
See the camera overlay view (available in 3.1 and later)