在你的cell里面加一个UILable,你需要做的是计算你的内容的高度,然后在
heightForRowAtIndexPath里面设置你的cell的高度。这是一种方法: #define CELL_CONTENT_WIDTH
320.0f (你的cell的宽度) #define CELL_CONTENT_MARGIN 10.0f CGSize cons
可以这样:
UIScrollView *scrollView = [[UIScrollView alloc]init];
scrollView.backgroundColor = [UIColor greenColor];
[self.view addSubview:scrollView];
scrollView.translatesAutoresizingMaskIntoConstraints = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
NSString *vflH = @"H:|-10-[scrollView]-10-|";
NSDictionary *views = NSDictionaryOfVariableBindings(scrollView);
NSArray *constraintsH = [NSLayoutConstraint constraintsWithVisualFormat:vflH
options:kNilOptions
metrics:nil
views:views];
[NSLayoutConstraint activateConstraints:constraintsH];
NSString *vflV = @"V:|-74-[scrollView]-10-|";
NSArray *constraintsV = [NSLayoutConstraint constraintsWithVisualFormat:vflV
options:kNilOptions
metrics:nil
views:views];
[NSLayoutConstraint activateConstraints:constraintsV];
[scrollView layoutIfNeeded];
CGFloat Width = scrollView.bounds.size.width;
CGFloat Heigh = scrollView.bounds.size.height;
NSLog(@"Width:%f\nHeigh:%f",Width,Heigh);