代码之家  ›  专栏  ›  技术社区  ›  JuanF

如何在iOS上显示RadListView

  •  0
  • JuanF  · 技术社区  · 7 年前

    <GridLayout row="7" col="0" colSpan="3" rows="*" cols="*">
         <RadListView [items]="sourcesOptions" height="100%">
               <ng-template tkListItemTemplate let-item="item">
                     <StackLayout orientation="horizontal">
                           <Switch [checked]="true" class="switch"></Switch>
                           <Label [text]="item.label" textWrap="true" marginTop="15"></Label>
                     </StackLayout>
               </ng-template>
               <ListViewGridLayout tkListViewLayout itemHeight="200" scrollDirection="Vertical" spanCount="2"></ListViewGridLayout>
         </RadListView>
    </GridLayout>
    

    它在Android上工作,但在iOS上没有显示任何东西。

    注意

    感谢您的帮助!!

    3 回复  |  直到 7 年前
        1
  •  1
  •   JuanF    7 年前

    问题是在项目异步时的高度,在这种情况下,我需要手动将高度设置为RadListView组件的父布局(在我的示例中是GridLayout)。

    如果我用百分比(100%)来设置高度是不起作用的,它必须是一个固定的数字,这很不方便,因为项目的数量并不总是相同的,所以我创建了一个函数来根据收到的项目的数量来设置高度。

    这是修复此问题的代码:

    <GridLayout row="7" col="0" colSpan="3" rows="*" cols="*" [height]="setHeight()">
         <RadListView [items]="sourcesOptions">
              <ng-template tkListItemTemplate let-item="item">
                   <StackLayout orientation="horizontal">
                        <Switch [checked]="true" class="switch"></Switch>
                        <Label [text]="item.label" textWrap="true" marginTop="15"></Label>
                   </StackLayout>
              </ng-template>
              <ListViewGridLayout tkListViewLayout itemHeight="70" scrollDirection="Vertical" spanCount="2"></ListViewGridLayout>
         </RadListView>
    </GridLayout>
    
        2
  •  0
  •   Brad Martin    7 年前

    尝试RLV组件的高度值,如 height="100%" 所以它充满了父母。iOS不像android那样自动布局,这就是为什么你会遇到这样的情况:)

        3
  •  0
  •   Ian MacDonald    7 年前

    你还没有提供 rows columns 为您的 GridLayout . 这个 RadListView 可能会出现,如果您:

    <GridLayout row="7" col="0" colSpan="3" rows="*" columns="*">