我在使用Cordova / Phonegap为iOS7构建应用程序时遇到了一个问题。我无法很好地隐藏iOS7状态栏。
最初我进入Xcode中的plist并添加了所有正确的设置,使状态栏不可见,就像在此解决方案Cannot hide status bar in iOS7中一样。
这很有效,直到我遇到了Cordova CAMERA API。当我的应用程序转到相机胶卷选择图像(然后将其插入屏幕)。选择图像并返回应用程序后,状态栏将再次可见。
我已经安装了状态栏cordova插件,我正在尝试隐藏状态栏,一旦它从相机设备返回到我的应用程序。惊喜 - 它不起作用!但是我可以启用一个按钮来调用一个函数来点击状态栏 - 但我想让它自动发生。
我在下面插入了我的代码:
<div id="Ccamera-fun" data-role="page" data-title="Camera Fun Activity">
<div data-role="header" data-theme="e">
<a href="#" data-rel="back" data-theme="h" data-icon="arrow-l" data-direction="reverse">Back</a>
<h1>3.5 years - 4.5 years</h1>
</div>
<div data-role="content" data-theme="a" class="content">
<h1>Camera Fun</h1>
<div id="imageContainer"></div>
<p>Use your photos and ask your child to describe one in detail. Use your photos as picture talks where your child can share their memories and recall events before or after the photo was taken. <strong>Together you could invent their own story.</strong></p>
<p>Use the buttons below to take a picture with your phone or select an image from your phone’s Photo Library. Once you have selected a photo, it will be embedded into the top of this screen.</p>
<script type="text/javascript" charset="utf-8">
function hideStatus() {
StatusBar.hide();
navigator.notification.alert("status bar hidden");
}
function takePhoto() {
navigator.camera.getPicture(onCameraSuccess,
onCameraError,
{quality: 50,
destinationType : Camera.DestinationType.FILE_URI});
}
function onCameraSuccess(imageURL) {
//HIDE STATUS BAR IMAGE
StatusBar.hide();
//GET A HANDLE TO THE IMAGE CONTAINER DIV
ic = document.getElementById('imageContainer');
//THEN WRITE AN IMAGE TAG OUT TO THE DIV USING THE URL WE RECEIVED FROM CAMERA APPLICATION
ic.innerHTML = '<img src="' + imageURL + '" width="100%" />';
navigator.notification.alert("onCameraSuccess:" + imageURL);
}
function onCameraError(e) {
console.log(e);
navigator.notification.alert("onCameraError:" + e);
}
function fromAlbum() {
navigator.camera.getPicture(onLibrarySuccess,
onLibraryError,
{quality: 50,
sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
allowEdit : true,
destinationType : Camera.DestinationType.FILE_URI});
}
function onLibrarySuccess(imageURL) {
//GET A HANDLE TO THE IMAGE CONTAINER DIV
ic = document.getElementById('imageContainer');
//THEN WRITE AN IMAGE TAG OUT TO THE DIV USING THE URL WE RECEIVED FROM CAMERA APPLICATION
ic.innerHTML = '<img src="' + imageURL + '" width="100%" />';
navigator.notification.alert("onCameraSuccess:" + imageURL);
}
function onLibraryError(e) {
console.log(e);
navigator.notification.alert("onCameraError:" + e);
}
</script>
<button onclick="takePhoto();" data-theme="h">Take a Picture</button>
<button onclick="fromAlbum();" data-theme="h">Choose a Picture</button>
<button onclick="hideStatus();" data-theme="h">Hide status bar</button>
</p>
</div>
</div>
如果有人能告诉我这里的错误,我会很感激。
由于
答案 0 :(得分:1)
这是一个手机错误,请参阅CB-5265:
您可以通过添加
来解决此问题 [[UIApplication sharedApplication] setStatusBarHidden:YES];
到imagePickerController的末尾:didFinishPickingMediaWithInfo:驻留在CDVCamera.m中
但是,上面的代码只是一个快速解决方案,没有全面考虑,你应该自己测试一下。
我希望这可以帮到你!
答案 1 :(得分:0)
Imnbeyond的解决方案对我不起作用。 我不得不进入我的plist,改变
View controller-based status bar appearance = YES
然后通过覆盖每个方法中的prefersStatusBarHidden来控制视图控制器中的状态栏,
-(BOOL)prefersStatusBarHidden{
return YES;
}