我是 Objective-C 的新手,我需要根据 ScrollView 的内容设置动态高度。我有一个 UIView,里面有 UIScrollView。我在视图上有一些 UILabel、UIButtons 等。现在它显示了额外的空间,即使我没有数据我也可以滚动到底部。所以如果数据完成我需要停止滚动。我该怎么做?
[testscroll setScrollEnabled:YES];
[testscroll setContentSize:CGSizeMake(320,800)];//static size to UISCrollView
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UIButton *button=[[UIButton alloc] initWithFrame:rect];
[button setFrame:rect];
[button setContentMode:UIViewContentModeLeft];
NSString *settitle=[NSString stringWithFormat:@"%@",item.Name];
[button setTitle:settitle forState:UIControlStateNormal];
NSString *tagValue=[NSString stringWithFormat:@"%d%d",indexPath.section+1,i];
button.tag=[tagValue intValue];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[hlcell.contentView addSubview:button];
[button release];
}
任何帮助,将不胜感激。