【问题标题】:NativeScript Place Disclosure Indicator on ListView Rows for iOS适用于 iOS 的 ListView 行上的 NativeScript Place Disclosure Indicator
【发布时间】:2016-07-09 19:23:55
【问题描述】:

我的 NativeScript 页面中有这样的结构:

<ListView #listView [items]="summaryData" row="0">
    <Template let-item="item">
        <GridLayout columns="180, *, auto" rows="auto, *">
            <Label [text]="item.name" col="0" class="summary"></Label>
            <Label [text]="item.value" col=1 class="summary"></Label>
        </GridLayout>
    </Template>
</ListView>

对于 iOS 端,我想为表格视图单元格使用本机披露指示器。我可以使用以下代码删除分隔线:

@ViewChild("listView") listView: ElementRef;

ngOnInit() {
    this.summaryData = this._summaryService.load();
    if (this._page.ios) {
        let iosListView = <ListView>this.listView.nativeElement;
        iosListView.ios.separatorStyle = 0; // Removes the separator lines.
    }
}

但我似乎无法弄清楚如何到达各个行,也就是 UITableViewCell 来设置附件类型值。 NativeScript 可以做到这一点吗?

【问题讨论】:

    标签: ios uitableview typescript angular nativescript


    【解决方案1】:

    您需要订阅 ListView 的itemLoading,然后在此处更改accessoryType。所以你的 html 应该是这样的:

    <ListView #listView [items]="summaryData" (itemLoading)="onItemLoading($event)" row="0">
        <Template let-item="item">
            <GridLayout columns="180, *, auto" rows="auto, *">
                <Label [text]="item.name" col="0" class="summary"></Label>
                <Label [text]="item.value" col=1 class="summary"></Label>
            </GridLayout>
        </Template>
    </ListView>
    

    然后在你的组件中拥有:

    import {ItemEventData} from "ui/list-view";
    
    onItemLoading(args: ItemEventData) {
       if (args.ios) {
           // args.ios is instance of UITableViewCell
           args.ios.accessoryType = 1; // UITableViewCellAccessoryDisclosureIndicator
       }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 2017-11-08
      • 1970-01-01
      相关资源
      最近更新 更多