Hide UIImagePickerControllerSourceTypceCamera toolbar, but specific buttons?

偶尔善良 提交于 2019-12-07 21:09:56

问题


In order to make my custom toolbar in my UIImagePickerControllerSourceTypeCamera, I have to turn off the camera control like this:

pickerOne.showsCameraControls = YES;

I want to show the zoom, flash, switch cameras, and focus on the UIImagePickerController, but I want to create my custom view. When adding my custom view, it only shows up if I turn off the cameraControls.

Is there any way to not hide the camera controls and make my custom view? Or will I have to manually add those buttons in?


回答1:


You can ignore the touches on your overlayview by checking the receiving view in the hittest method. Just add this code to your overlay view, than all touches on that view will be ignored, but not the ones on its subviews.

-(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    id hitView = [super hitTest:point withEvent:event];
    if (hitView == self) return nil;
    else return hitView;
}

If read this today on stackoverflow, but i don't remember where, sry.




回答2:


I believe there is no other way(at least in a direct way) than to implement the native functionality in your custom view (overlay).
Other approach (which i havent tried) is to add custom view (not to use cameraOverlay property) to the UIImagePickerController rootview. This is not suggested/allowed but seems like it will work. The reason autoflash/zoom/front camera ... dont work with custom view is, the view hierarchy is different.

If you look at popular camera apps, most of them implement these controls. Also , i did the same.
As a matter of fact it should'nt be difficult to implement them. 'Tap to focus' is tricky to implement,the actual focus is done by default. All we need to do is to draw the square around the touch.



来源:https://stackoverflow.com/questions/6240960/hide-uiimagepickercontrollersourcetypcecamera-toolbar-but-specific-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!