【发布时间】:2016-12-16 06:08:35
【问题描述】:
在一个数组中,我有一个字符串和一个数组,我想在自定义单元格中动态显示它。我的数组结构如下所示。它会根据来自网络服务的数据而变化。
{
subDescription = (
"Worship Hours 5.00am to 12.30pm & 4.00pm to 10.00pm",
"The temple is open all days of the week"
);
subHeading = Hours;
}
我试过这样使用这种格式我可以显示subHeading 值只如何显示subDescription 数组
float xCoordinate=10.0,yCoordinate=30.0,width=320,height=40;
float ver_space=20.0;
for (int i = 0; i <test.count; i++)
{
NSDictionary *lanuage=[test objectAtIndex:i];
NSString *work=[lanuage objectForKey:@"subHeading"];
NSArray *er=[lanuage objectForKey:@"subDescription"];
UILabel *label = [[UILabel alloc] initWithFrame:
CGRectMake(xCoordinate,yCoordinate,width,height)];
label.text = work;
[events.contentView addSubview:label];
yTCoordinate=yTCoordinate+heightT+ver_space;
}
【问题讨论】:
-
您的问题标题具有误导性。您是要动态创建两个标签,还是在检索 subDescription 时遇到问题???
-
我想动态创建两个标签,获取它对我来说没问题。创建 subHeading 后,我需要显示 subDescription 数组元素。
标签: ios objective-c arrays uilabel custom-cell