<core:FragmentDefinition xmlns="sap.m"xmlns:f="sap.ui.layout.form" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:l="sap.ui.layout">
<Page id="tileInfo" showHeader="false" enableScrolling="true" >
<TileContainer
id="getTiles"
tiles="{myModel1>TILECOLLECTION}">
<StandardTile
icon="{myModel1>icon}"
number="{myModel1>number}"
info="{myModel1>info}"
infoState="{myModel1>infostate}"
title="{myModel1>title}"
numberUnit="{myModel1>numberunit}"
press="handleTilePress"
class="myGreen"
/>
</TileContainer>
</Page>
</core:FragmentDefinition>
我想读取视图控制器中TileContainer中的每个tile。有可能吗?
答案 0 :(得分:1)
在控制器中:
NSString *sliderimage01 = [imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHolderImage1"]];
NSString *sliderimage02 = [imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHolderImage2"]];
NSString *sliderimage03 = [imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHolderImage3"]];
NSString *sliderimage04 = [imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHolderImage4"]];
NSString *sliderimage05 = [imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHolderImage5"]];
self.imagesData = @[sliderimage01, sliderimage02, sliderimage03, sliderimage04, sliderimage05];
for(int i=0; i<self.imagesData.count;i++){
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetWidth(self.view.frame) * i, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.scrollView.frame))];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.image = [UIImage imageNamed:[self.imagesData objectAtIndex:i]];
[self.scrollView addSubview:imageView];
}
self.scrollView.delegate = self;
index=0;
数组中的aTiles是tile容器的tile聚合的tile。
答案 1 :(得分:0)
使用嵌套视图而不是片段。 code with nested views
然后你可以获得瓷砖并在下面应用逻辑。
var oTileContainer = this.byId("myView--getTiles");
var aTilesLength = oTileContainer.getTiles().length;
for(var i = 0 ;i<aTilesLength;i++){
if(i%2 == 1){
oTileContainer.getTiles()[i].addStyleClass("blue");
}else{
oTileContainer.getTiles()[i].addStyleClass("green");
}
}
答案 2 :(得分:0)
我添加了更多信息。如果我们不通过,我们可以使用以下代码来获取片段详细信息:
全部谢谢。 注意:代码在onInit函数中不起作用,但在其他函数中起作用
var fragmentId = this.getView().createId("myFragment");
var tileContainer = sap.ui.core.Fragment.byId(fragmentId,"getTiles");
var oTiles = tileContainer.getTiles();