TabView 在 ios nativescript 上停留在顶部
TabView stick at the top on ios nativescript
我正在使用选项卡视图显示数据,但是 android 和 IOS 方向不同(android 在顶部,IOS 在底部),我怎样才能像顶部的 android 那样做 ios?没有设置属性吗?
在 iOS 中无法将选项卡视图固定在顶部。你可以用同样的方式使用。 SegmentedBar。我举个例子:
主要-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>
主要-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;
我正在使用选项卡视图显示数据,但是 android 和 IOS 方向不同(android 在顶部,IOS 在底部),我怎样才能像顶部的 android 那样做 ios?没有设置属性吗?
在 iOS 中无法将选项卡视图固定在顶部。你可以用同样的方式使用。 SegmentedBar。我举个例子:
主要-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>
主要-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;