admin管理员组文章数量:1024128
I want to use native tab bar of iphone using phonegap. I have used the code and plugin shown in :-UIControls-%28TabBar%29. But the tab bar did not display. Can anyone help me to get tab bar in my application?
I want to use native tab bar of iphone using phonegap. I have used the code and plugin shown in http://wiki.phonegap./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?
Share Improve this question edited Aug 2, 2011 at 13:19 The_Fox 7,0622 gold badges47 silver badges70 bronze badges asked Jul 15, 2011 at 6:30 HimaHima 2071 gold badge6 silver badges14 bronze badges4 Answers
Reset to default 2It is quite easy. Normally this will not happen, because you are adding a forth parameter.
The TabBar is expecting this forth parameter or null. But the test if this exist is buggy.
So just put in forth dummy item --> {( foo : "bar" )} <---
plugins.tabBar.createItem("Advent Calendar",
"Sven Elch",
"abc.png",
{ foo : "bar" } // <-----
);
or patch if condition in TabBar.m (line 334 or so).
if(options != [NSNull null])
{
id badgeOpt = [options objectForKey:@"badge"];
if(badgeOpt && badgeOpt != [NSNull null])
item.badgeValue = [badgeOpt stringValue];
}
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>
I believe that plugin got deprecated. Go to http://github./phonegap/phonegap-plugins/. In there you will see a plugin called native control under iPhone. That is the plugin you want to use.
After you download it, add the nativecontrols files to your plugin folder in your project. Add NativeControls as a key and value in phonegap.plist file. Add the nativecontrols js file to your www directory. Then you can create, show, etc your tabbar
Steps (might be the same for any plugin):
- Get the plugin iOS NativeControls
- Copy *.xib, *.m and *.h files to your project's "Plugins" folder (should already exist and contain a README file)
- They have to be added to the project as well, so drag them from the "Plugins" folder (in Finder) to the same folder (in Xcode) and select to create references
- Open "Resources/Cordova.plist" and under "Plugins", add a key with the plugin name "NativeControls" and a string value of "NativeControls" (I guess it's the plugin's main class name)
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)
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 bee 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 want to use native tab bar of iphone using phonegap. I have used the code and plugin shown in :-UIControls-%28TabBar%29. But the tab bar did not display. Can anyone help me to get tab bar in my application?
I want to use native tab bar of iphone using phonegap. I have used the code and plugin shown in http://wiki.phonegap./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?
Share Improve this question edited Aug 2, 2011 at 13:19 The_Fox 7,0622 gold badges47 silver badges70 bronze badges asked Jul 15, 2011 at 6:30 HimaHima 2071 gold badge6 silver badges14 bronze badges4 Answers
Reset to default 2It is quite easy. Normally this will not happen, because you are adding a forth parameter.
The TabBar is expecting this forth parameter or null. But the test if this exist is buggy.
So just put in forth dummy item --> {( foo : "bar" )} <---
plugins.tabBar.createItem("Advent Calendar",
"Sven Elch",
"abc.png",
{ foo : "bar" } // <-----
);
or patch if condition in TabBar.m (line 334 or so).
if(options != [NSNull null])
{
id badgeOpt = [options objectForKey:@"badge"];
if(badgeOpt && badgeOpt != [NSNull null])
item.badgeValue = [badgeOpt stringValue];
}
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>
I believe that plugin got deprecated. Go to http://github./phonegap/phonegap-plugins/. In there you will see a plugin called native control under iPhone. That is the plugin you want to use.
After you download it, add the nativecontrols files to your plugin folder in your project. Add NativeControls as a key and value in phonegap.plist file. Add the nativecontrols js file to your www directory. Then you can create, show, etc your tabbar
Steps (might be the same for any plugin):
- Get the plugin iOS NativeControls
- Copy *.xib, *.m and *.h files to your project's "Plugins" folder (should already exist and contain a README file)
- They have to be added to the project as well, so drag them from the "Plugins" folder (in Finder) to the same folder (in Xcode) and select to create references
- Open "Resources/Cordova.plist" and under "Plugins", add a key with the plugin name "NativeControls" and a string value of "NativeControls" (I guess it's the plugin's main class name)
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)
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 bee 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.
本文标签: javascriptnative Tab bar of iphone in phonegapStack Overflow
版权声明:本文标题:javascript - native Tab bar of iphone in phonegap - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745587125a2157663.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论