[英]native Tab bar of iphone in phonegap
I want to use native tab bar of iphone using phonegap.我想使用 phonegap 使用 iphone 的本机标签栏。 I have used the code and plugin shown in http://wiki.phonegap.com/w/page/16494801/iPhone:-UIControls-%28TabBar%29 .
我使用了http://wiki.phonegap.com/w/page/16494801/iPhone:-UIControls-%28TabBar%29中显示的代码和插件。 But the tab bar did not display.
但是标签栏没有显示。 Can anyone help me to get tab bar in my application?
谁能帮我在我的应用程序中获取标签栏?
It is quite easy.这很容易。 Normally this will not happen, because you are adding a forth parameter.
通常这不会发生,因为您要添加第四个参数。
The TabBar is expecting this forth parameter or null. TabBar 期待第四个参数或 null。 But the test if this exist is buggy.
但是测试是否存在是错误的。
So just put in forth dummy item --> {( foo: "bar" )} <---所以只需提出虚拟项目 --> {( foo: "bar" )} <---
plugins.tabBar.createItem("Advent Calendar",
"Sven Elch",
"abc.png",
{ foo : "bar" } // <-----
);
or patch if condition in TabBar.m (line 334 or so).或修补 TabBar.m 中的条件(第 334 行左右)。
if(options != [NSNull null])
{
id badgeOpt = [options objectForKey:@"badge"];
if(badgeOpt && badgeOpt != [NSNull null])
item.badgeValue = [badgeOpt stringValue];
}
Steps (might be the same for any plugin):步骤(任何插件都可能相同):
Try the following example ( NOTE: this example is from 2012-06-28, I'm actually working on an improved version that removes the toolbar functionality and replaces it with an actually working navigation bar – see here )试试下面的例子(注意:这个例子来自 2012 年 6 月 28 日,我实际上正在开发一个改进的版本,它删除了工具栏功能并将其替换为一个实际工作的导航栏——见这里)
window.plugins.nativeControls.createTabBar() window.plugins.nativeControls.createTabBarItem('home', 'Home', 'tabButton:Contacts') window.plugins.nativeControls.showTabBar() window.plugins.nativeControls.showTabBarItems('home') window.plugins.nativeControls.createToolBar() window.plugins.nativeControls.setToolBarTitle('Hello toolbar.') window.plugins.nativeControls.showToolBar() alert("Tabs and toolbar should now become visible")
I can't get the title of the toolbar to work, though, but both the tab and the toolbar itself (without text) is showing.但是,我无法让工具栏的标题正常工作,但选项卡和工具栏本身(没有文本)都在显示。
I believe that plugin got deprecated.我相信该插件已被弃用。 Go to http://github.com/phonegap/phonegap-plugins/ .
Go 到http://github.com/phonegap/phonegap-plugins/ 。 In there you will see a plugin called native control under iPhone.
在那里,您将看到一个名为 iPhone 下的原生控件的插件。 That is the plugin you want to use.
那就是您要使用的插件。
After you download it, add the nativecontrols files to your plugin folder in your project.下载后,将 nativecontrols 文件添加到项目中的插件文件夹中。 Add NativeControls as a key and value in phonegap.plist file.
在 phonegap.plist 文件中添加 NativeControls 作为键和值。 Add the nativecontrols js file to your www directory.
将 nativecontrols js 文件添加到您的 www 目录。 Then you can create, show, etc your tabbar
然后你可以创建、显示等你的标签栏
Just try this:试试这个:
<script>
var moreNum = 1;
plugins.nativeControls.createToolBar();
plugins.nativeControls.setToolBarTitle("hello");
plugins.nativeControls.createTabBar();
plugins.nativeControls.createTabBarItem("search","search","tabButton:Search");
plugins.nativeControls.createTabBarItem("book","book","tabButton:Contacts");
plugins.nativeControls.createTabBarItem("more","more","tabButton:More",{"onSelect":function(){
plugins.nativeControls.updateTabBarItem("more",{"badge":((++moreNum).toString())});
}});
plugins.nativeControls.showTabBar();
plugins.nativeControls.showTabBarItems("book","search","more");
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.