2010-02-16 21 views
7

Vorrei scorrere il mio contenuto in un UIScrollView. Ma penso di aver fatto un errore.UIScrollView: lo scorrimento non funziona

// 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]; 

risposta

7

Invece di impostare grande cornice è necessario impostare la dimensione del contenuto del 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

Sì, grazie !!! – fabian

Problemi correlati