Cordova InAppBrowser - 如何禁用URL和导航栏? [英] Cordova InAppBrowser - How to disable URL and Navigation Bar?

查看:230
本文介绍了Cordova InAppBrowser - 如何禁用URL和导航栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在建立一个新闻聚合器应用程序,我使用InAppBrowser为人们阅读文章。现在,我的问题是:我可以删除的URL和导航栏吗?

I am currently building a News Aggregator App and I am using InAppBrowser for people to read the articles. Now, my questions is: Can I remove the URL and Navigation Bar? Also, can I change the "Done" button text?

请让我知道...

谢谢!

>

推荐答案

要移除网址,只需将位置选项设置为否。

To remove the URL, just set the location option to "no".

var ref = cordova.InAppBrowser('http://apache.org', '_blank', 'location=no');

最近的Cordova / PhoneGap版本现在允许您通过添加' closebuttoncaption'选项。

Recent versions of Cordova/PhoneGap now allow you to change the 'Done' button text by adding a 'closebuttoncaption' option.

var ref = cordova.InAppBrowser('http://apache.org', '_blank', 'closebuttoncaption=My Button Name');

正如danw所说,你现在也可以通过将'toolbar'选项设置为 no。

As danw mentioned, you can now also remove the entire toolbar by setting the 'toolbar' option to "no".

var ref = cordova.InAppBrowser('http://apache.org', '_blank', 'toolbar=no');

但是,删除工具栏意味着后退/前进按钮和完成不再显示。这使得很难退出InAppBrowser。

However, removing the toolbar means both the 'Back/Forward' buttons and the 'Done' button will no longer show. This makes it difficult to exit out of the InAppBrowser.

如果你想保留'完成'按钮,而是摆脱所有的'后退/转发'按钮您的InAppBrowser可以按如下方式修改InAppBrowser插件的源代码。

If you want to keep the 'Done' button, but get rid of the 'Back/Forward' buttons in all of your InAppBrowsers, you can modify the source code for the InAppBrowser plugin as follows.

对于iOS,打开以下文件:

For iOS, open the following file

YOURAPPNAME/platforms/ios/YOURAPPNAME/Plugins/cordova-plugin-inappbrowser/CDVInAppBrowser.m

并更改以下代码行:

[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];

到:

[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]];

然后使用命令行再次构建项目。

Then build your project again using the command line.

于2016年2月使用Cordova 6.0.0,Cordova iOS 4.0.1和cordova-plugin-inappbrowser 1.2.0测试

Tested Feb 2016 with Cordova 6.0.0, Cordova iOS 4.0.1 and cordova-plugin-inappbrowser 1.2.0

这篇关于Cordova InAppBrowser - 如何禁用URL和导航栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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