0

表示されたラベルのリストから特定のラベルのテキストを解析して、ラベルのUIScrollView次のビューに表示しようとしています。しかし、これらのラベル テキストは から取得しましたNSMutableArray。私は試しましたがNSMutableArray、Refの次のコードを参照してください:Plzは私が何をするかを提案します

-(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];

}
4

1 に答える 1

0

ラベルの特定の名前を取得するタグを付けて、私の以下のコードをあなたのコードに置き換えてください...

-(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.tag = 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.tag = i;
        [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:(id)sender
     {
       UIButton *btnTemp = (UIButton*)sender;
       Details *detailsPage=[[Details alloc]initWithNibName:@"Details" bundle:nil];

       detailsPage.pplName=[totalData objectAtIndex:btnTemp.tag];

     [self presentModalViewController:detailsPage animated:YES];

    }
于 2012-11-02T07:43:11.683 に答える