0

我目前有一个-UIScrollView并且我有一个在scrollView中添加更多信息的函数,但是在函数内部它重新计算scrollView的大小,我尝试让它更大但它保持不变。

基本上在它里面-viewDidLoad 设置了“默认”大小-UIScrollView

[self.xboxScrollView setContentSize:CGSizeMake(303, 2890)];

一段时间后,该设备将一些其他值添加到-UIScrollView

- (void)addAnotherCheat:(NSString *)title :(NSString *)description index:(NSInteger)cheatID {
    int titleLocation = 2744 + (cheatID * 101);
    int titleDescription = 2766 + (cheatID * 101);
    float lengthofscrollViews = 2866 + (cheatID * 101);

        cheat1 = [[UILabel alloc] initWithFrame:CGRectMake(13, titleLocation, 287, 35)];
        description1 = [[UILabel alloc] initWithFrame:CGRectMake(13, titleDescription, 287, 71)];
        image1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, titleLocation, 306, 91)];
        UIImage *image = [UIImage imageNamed: @"backggroundcolor.png"];

        [self.xboxScrollView setContentSize:CGSizeMake(303, lengthofscrollViews)];
        [self.xboxScrollView setScrollEnabled:YES];


            NSLog(@"Scrollview Size : %f", self.xboxScrollView.contentSize.height);
        [self.xboxScrollView addSubview:image1];
        [self.xboxScrollView addSubview:cheat1];
        [self.xboxScrollView addSubview:description1];
        image1.image = image;
        cheat1.backgroundColor=[UIColor clearColor];
        cheat1.textColor = [UIColor whiteColor];
        description1.backgroundColor=[UIColor clearColor];
        description1.textColor = [UIColor whiteColor];
        description1.numberOfLines = 3;
        [cheat1 setFont:[UIFont fontWithName:@"STHeitiTC-Medium" size:19.0f]];
        [description1 setFont:[UIFont fontWithName:@"STHeitiTC-Light" size:16.0f]];

        cheat1.text = title;
        description1.text = description;
 }

当我记录它应该是它的大小时,它会打印出我想要的正确高度,但它不会改变高度。

基本上,当我已经设置了 ContentSize 时,我需要一种方法来使 scrollView 更大。

4

0 回答 0