【问题标题】:TabView stick at the top on ios nativescriptTabView 贴在 ios nativescript 的顶部
【发布时间】:2019-02-12 21:03:39
【问题描述】:

我正在使用标签视图显示数据,但是在 android 和 IOS 中方向不同(顶部是 android,底部是 IOS),我怎样才能像顶部的 android 一样做 ios?没有属性可以设置吗?

【问题讨论】:

    标签: nativescript


    【解决方案1】:

    在 iOS 中,无法将选项卡视图粘贴在顶部。你可以以同样的方式使用。 SegmentedBar。我给你举个例子:

    主页.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

    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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-28
      • 1970-01-01
      • 2019-02-16
      • 1970-01-01
      • 2012-08-05
      • 2020-12-02
      • 1970-01-01
      相关资源
      最近更新 更多