我创建了一个NSarray
,现在我想根据它们的索引在标签中显示它的数据。
但不想在表格视图单元格中显示它们 我想用简单的标签显示它们。
答案 0 :(得分:1)
for (int i=0; i<[yourArr count]; i++) {
yourLblObject.text=[NSString stringWithFormat:@"%@",[yourArr objectAtIndex:i]];
}
答案 1 :(得分:1)
使用此代码我认为这对您有所帮助
-(void)viewdidload
{
playerScores = [[NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",nil] retain];
CGFloat y = 20;
for (int i = 0;i<[playerScores count];i++) {
myLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, y, 60, 60)];
myLabel.backgroundColor=[UIColor clearColor];
[myLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:35]];
NSString *text = [NSString stringWithFormat:[playerScores objectAtIndex:i]];
[myLabel setText:text];
[yardsScrollView addSubview:myLabel];
[myLabel release];
y = y+125;
}
}