如何摆脱IOS中的scrollview滚动内容?

时间:2015-05-18 12:39:41

标签: ios objective-c iphone uiscrollview contentsize

我以编程方式创建了滚动视图,并正确设置了所有内容大小和框架。

虽然它在iPhone 4和4s中造成了问题。

在iPhone 5中它工作正常....

查看附件图片.... in iPhone 4s it looks like this

enter image description here

    viewFirst = [[UIView alloc]initWithFrame:CGRectMake(10, objScrollView.frame.origin.y+30, 30, objScrollView.frame.size.height-30)];
    UIScrollView *scrollViewFirst = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, viewFirst.frame.size.width, viewFirst.frame.size.height)];

    int yy = 10;
    int height = 25;
    for (int i = 0; i<12; i++)
    {

        if (i!=0)
        {
            UILabel *lblIncremental;

            if (i==10)
            { // This is my IN label which is in iPhone 5s 
                lblIncremental = [[UILabel alloc]initWithFrame:CGRectMake(-8, yy+8, height+21, 30)];
                [lblIncremental setText:@"IN"];
                [lblIncremental setBackgroundColor:[UIColor redColor]];
                lblIncremental.transform = CGAffineTransformMakeRotation(-M_PI/2);
                yy = yy + height + 20;
            }
            else if (i==11)
            {
               //This is my Total label which is in iPhone 5s 

                lblIncremental = [[UILabel alloc]initWithFrame:CGRectMake(-10, yy+10, 49, 31)];
                [lblIncremental setText:@"TOTAL"];
                lblIncremental.transform = CGAffineTransformMakeRotation(-M_PI/2);
                yy = yy + height + 24;
            }
            else
            {
                lblIncremental = [[UILabel alloc]initWithFrame:CGRectMake(0, yy, 30, height)];
                [lblIncremental setText:[NSString stringWithFormat:@"%d",i]];
                yy = yy + height;
            }
            [lblIncremental setTextColor:GET_COLOR_WITH_RGB(64, 176, 102, 1)];
            [lblIncremental setFont:UI_DEFAULT_FONT_REGULAR(11.0f)];
            [lblIncremental setTextAlignment:NSTextAlignmentCenter];
            [scrollViewFirst addSubview:lblIncremental];
        }
        else
        {
            UIButton *imgView = [[UIButton alloc]initWithFrame:CGRectMake(7.5, 10, 15, 15)];
            [imgView setBackgroundImage:[UIImage imageNamed:@"clubAtlasFlag"] forState:UIControlStateNormal];
            [imgView.layer setMasksToBounds:YES];
            [scrollViewFirst addSubview:imgView];
            yy = yy + height;
        }
    }
    [scrollViewFirst setContentSize:CGSizeMake(30, yy)];
    [scrollViewFirst setBackgroundColor:[UIColor blackColor]];
    [viewFirst addSubview:scrollViewFirst];
    [viewFirst setHidden:YES];
//    [viewFirst setBackgroundColor:[UIColor redColor]];
    [scrollViewFirst setBackgroundColor:[UIColor clearColor]];
    [self.view addSubview:viewFirst];

1 个答案:

答案 0 :(得分:0)

如果您将角半径应用于UIScrollview(即scrollViewFirst),则将其删除或再次检查此代码。我确信应用的半径代码可能有问题。