Wie würde ich über die dynamische Anpassung der Höhe eines UIScrollView
gehen? Grundsätzlich habe ich eine Reihe von UILabels
, die erstellt werden (die genaue Anzahl der UILabels ist zufällig) und die UIScrollView
ist seine Höhe automatisch anpassen, um die UILables
unterzubringen. Das habe ich bisher in der viewDidLoad
.UIScrollView automatisch anpassen Höhe
- (void)viewDidLoad
{
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(320
, 1500)];
scroller.indicatorStyle = UIScrollViewIndicatorStyleWhite;
{
Und dies ist die Aktion, die
-(IBAction)scheduale{
int i;
for(i=0; i<[self retrieveTime] ; i++){
//Add time label
UILabel *timeLabel = [[UILabel alloc] init];
timeLabel.frame = CGRectMake(10, (i+1) * 21, 31, 20);
timeLabel.textColor = [UIColor whiteColor];
timeLabel.backgroundColor = [UIColor colorWithRed:76.0/225.0 green:76.0/225.0 blue:76.0/225.0 alpha:1.0];
NSString *labelString;
labelString = [[NSNumber numberWithInt:i] stringValue];
timeLabel.text = labelString;
timeLabel.textAlignment = UITextAlignmentCenter;
//theLabel.tag = (i+1) * 100;
[scroller addSubview:timeLabel];
}
Bitte überprüfen Sie, dass Content richtig geht. – danh