如何将子视图添加到滚动视图的子视图 [英] how to add subview to subviews of scroll view

查看:32
本文介绍了如何将子视图添加到滚动视图的子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建此视图.添加滚动视图的代码

how create this view. code for adding scroll view

yPos=0;
for (int i=0; i<24; i++) {

    UIView *timeView=[[UIView alloc]initWithFrame:CGRectMake(71, yPos, 909, 60)];
    timeView.userInteractionEnabled=TRUE;
    timeView.exclusiveTouch=YES;
    if (i==4) {
        UIView *ssview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 80)];
        ssview.tag=1;
        ssview.userInteractionEnabled=TRUE;
        UILabel *recurenceId=[[UILabel alloc]init];
        recurenceId.text=@"A12334";

        [ssview addSubview:recurenceId];
        ssview.backgroundColor=[UIColor orangeColor];


        [timeView addSubview:ssview];
        [ssview addGestureRecognizer:tap];



    }

这里的 ssview 高度大于 timeview.so 它也被添加到下一个子视图

here ssview height is more than timeview.so it be added to next subview also

这里每一行都是滚动视图的一个子视图.现在我必须添加另一个绿色视图.

here every row is a subview of scroll view. Now i have to addd another view which is in green color.

推荐答案

NSArray *greenViewsIndexes=[NSArray arrayWithObjects:[NSNumber numberWithInt:5],[NSNumber numberWithInt:6],[NSNumber numberWithInt:11],[NSNumber numberWithInt:12], nil];   
for (int i=0; i<24; i++) {

for (int j=0; j>greenViews.count; j++) {
if ([[greenViews objectAtIndex:j]intValue]==i){
    UIView *greenView=[[UIView alloc]initWithFrame:CGRectMake(71,61*(j+1),100,80)];
    [greenView setBackgroundColor:[UIColor greenColor]];
    }
  }

  //another operations

}

这篇关于如何将子视图添加到滚动视图的子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆