0

行ごとにスクロールビューに20のサブビューを追加しました。

コードスニペット

yPos=0;
for (int i=0; i<20; i++)
{
    UIView *timeView=[[UIView alloc]initWithFrame:CGRectMake(71, yPos, 909, 60)];

    timeView.userInteractionEnabled=TRUE;
    timeView.exclusiveTouch=YES;
    timeView.tag=i;

    NSLog(@"sub vieww tag=:%d",timeView.tag);

    timeView.backgroundColor=[UIColor whiteColor];

    UILabel *lbltime=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 70, 60)];
    lbltime.text=@"VIEW HERE";
    lbltime.textColor=[UIColor grayColor];

    [timeView addSubview:lbltime];

    [scrlView addSubview:timeView];

    yPos=yPos+61;
}

これらの 20 個のサブビューに別のサブビューを追加するにはどうすればよいでしょうか?

4

4 に答える 4

1

すべてのビューをスクロールに追加したので、スクロールビューからUIViewを列挙し、別のサブビューをUIViewに追加します

for(UIView *myView in scrollview.subviews)
  {
   //Create UIView
   UIView *anotherSubView=[UIView alloc]initWithFrame:CGRectMake(0,0,20,20)];

   [myView addSubview:anotherSubview];
  }
于 2013-08-21T10:04:19.993 に答える
0

NSlog(@"サブビュー: %@",self.scrollView.subviews);

for(UIView *view in self.scrollView.subviews){

   // NSLog(@"View : %@",view);
    // you can add ur subview in this view
}
于 2013-08-21T10:06:24.473 に答える