TabView贴在iOS nativescript的顶部 [英] TabView stick at the top on ios nativescript
本文介绍了TabView贴在iOS nativescript的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用选项卡视图显示数据,但是在android和iOS中,方向是不同的(顶部是android,底部是ios),我该如何像顶部的ios一样进行ios操作呢?没有属性来设置它吗?
I'm using tab-view show the data, but in android and IOS is different direction(android at top and IOS at bottom), how can I do ios same like android at the top ? Isn't got properties to set it?
推荐答案
在iOS中,无法将选项卡视图置于顶部.您可以以相同的方式使用. SegmentedBar .我给你举个例子:
In iOS is not possible to stick the tab-view at the top. you could use in the same way. SegmentedBar. I am giving you an example:
main-page.xml
main-page.xml
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
<StackLayout>
<SegmentedBar selectedIndex="{{ selectedIndex }}">
<SegmentedBar.items>
<SegmentedBarItem title="First" />
<SegmentedBarItem title="Second" />
</SegmentedBar.items>
</SegmentedBar>
<StackLayout visibility="{{ isItemVisible }}" >
<Label text="Tab1" textWrap="true" />
</StackLayout>
<StackLayout visibility="{{ isItemVisibleSecond }}">
<Label text="Tab2" textWrap="true" />
</StackLayout>
</StackLayout>
</Page>
main-page.js
main-page.js
var observable_1 = require("data/observable"); // Event handler for Page "navigatingTo" event attached in main-page.xml function navigatingTo(args) {
// Get the event sender
var page = args.object;
var observable = new observable_1.Observable();
observable.set("selectedIndex", 0);
observable.set("isItemVisible", "visible");
observable.set("isItemVisibleSecond", "collapsed");
observable.addEventListener(observable_1.Observable.propertyChangeEvent, function (pcd) {
console.log(pcd.eventName.toString() + " " + pcd.propertyName.toString() + " " + pcd.value.toString());
if (pcd.propertyName.toString() == 'selectedIndex') {
if (pcd.value.toString() == 0) {
observable.set("isItemVisible", "visible");
observable.set("isItemVisibleSecond", "collapsed");
}
else {
observable.set("isItemVisible", "collapsed");
observable.set("isItemVisibleSecond", "visible");
}
}
});
page.bindingContext = observable;
}
exports.navigatingTo = navigatingTo;
这篇关于TabView贴在iOS nativescript的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文