ScrollView setContentSize不会使scrollView变大

时间:2013-09-30 15:17:16

标签: iphone ios objective-c uiscrollview

我目前有一个-UIScrollView,我有一个函数可以在scrollView中添加更多信息,但是在函数内部它重新计算了scrollView的大小,我试着让它更大但是它保持不变。 / p>

基本上在-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变大。

0 个答案:

没有答案