我正在尝试将特定标签的文本从标签列表中解析到标签中的UIScrollView
下一个视图中。但是这些标签文本来自NSMutableArray
. 我试过了,但我只得到了参考的最后一个值,NSMutableArray
请参阅以下代码:请建议我将做什么
-(void)dataPrinting
{
int t= 60;
NSLog(@"%@",totalData);
for (int i = 0; i < [totalData count]; i++)
{
pplname=[[UILabel alloc]initWithFrame:CGRectMake(10, t, 200, 30)];
pplname.backgroundColor=[UIColor clearColor];
pplname.text=[totalData objectAtIndex:i];
pplname.textColor=[UIColor redColor];
[scrollView addSubview:pplname];
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
//initWithFrame:CGRectMake(10, t, 200, 40) ];
button.frame=CGRectMake(10, t, 200, 40);
[button addTarget:self
action:@selector(nextview)
forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:button];
t=t+40;
}
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width, t+2)];
[aview stopAnimating];
}
-(IBAction)nextview
{
Details *detailsPage=[[Details alloc]initWithNibName:@"Details" bundle:nil];
for (int i = 0; i < [totalData count]; i++)
{
detailsPage.pplName=[totalData objectAtIndex:i];
}
[self presentModalViewController:detailsPage animated:YES];
}