2010-02-16 7 views
7

Je voudrais faire défiler mon contenu dans un UIScrollView. Mais je pense que j'ai fait une erreur.UIScrollView: défilement ne fonctionne pas

// setup view 
CGRect appFrame = [UIScreen mainScreen].applicationFrame; 
CGRect frame = CGRectMake(0, 0, appFrame.size.width, appFrame.size.height); 
self.view = [[[UIView alloc] initWithFrame:frame] autorelease]; 

// setup wrapper 
UIScrollView *wrapper = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, appFrame.size.width, appFrame.size.height + 320)]; 
wrapper.backgroundColor = [UIColor redColor]; 
wrapper.scrollEnabled = YES; 
[self.view addSubview:wrapper]; 

// title (simple version here) 
title.text = "Hello World"; 
[wrapper addSubview:title]; 

Répondre

7

Au lieu de fixer un grand cadre que vous devez définir la taille du contenu de UIScrollView:

UIScrollView *wrapper = [[UIScrollView alloc] initWithFrame: 
      CGRectMake(0, 0, appFrame.size.width, appFrame.size.height)]; 
wrapper.contentSize =CGSizeMake(appFrame.size.width, appFrame.size.height + 320); 
+0

ouais, merci !!! – fabian

Questions connexes