2013-03-15 4 views
2

Ce code montre le scrollView, mais l'image que je veux montrer (tutoriel) est plus grande que la vue. En d'autres termes tutorial.png est exactement 280X1200 mais il ne sera pas aspectFit. Il me manque un petit quelque chose ici:UIScrollView avec grande image

tipScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(20, 10, 280, 1200)]; 
tipScroll.showsVerticalScrollIndicator = YES; 
tipScroll.scrollEnabled = YES; 
tipScroll.userInteractionEnabled = YES; 

UIImageView *tutorialImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tutorial"]]; 

tipScroll.contentMode = UIViewContentModeScaleAspectFit; 
tutorialImageView.contentMode = UIViewContentModeScaleAspectFit; 

tipScroll.contentSize = tutorialImageView.frame.size; 

[self.view addSubview:tipScroll]; 
[tipScroll addSubview:tutorialImageView]; 

Répondre

2

S'il vous plaît regarder le code.It fonctionnera ci-dessous sous la direction

tipScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(20, 10, 280, 1200)]; 
tipScroll.showsVerticalScrollIndicator = YES; 
tipScroll.scrollEnabled = YES; 
tipScroll.userInteractionEnabled = YES; 

UIImageView *tutorialImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 280, 1200)]; 
tutorialImageView.image = [UIImage imageNamed:@"tutorial"]; 

tipScroll.contentSize = tutorialImageView.frame.size; 
[tipScroll addSubview:tutorialImageView]; 
[self.view addSubview:tipScroll]; 
Questions connexes