How to set content size of UIScrollView dynamically

前端 未结 11 1920
耶瑟儿~
耶瑟儿~ 2020-12-01 05:41

I got question about UIScrollview.

The story is I have a UIView named ChartsView which I re-draw it myself by override method drawRec

11条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 05:53

    Try this -

    - (void)viewDidLoad
        {
            [super viewDidLoad];
    
    // not this way. it's fixed size.....
            ChartsView *chartsView = [[ChartsView alloc]initWithFrame:CGRectMake(0, 0, 320, 800)]; 
    
            //self.scrollView.contentSize = chartsView.frame.size;
            [self.scrollView setContentSize:CGSizeMake(chartsView.frame.size.width, chartsView.frame.size.height)];
            [self.scrollView addSubview:chartsView];
    
        }
    

提交回复
热议问题