2013-03-15 191 views
2

此代碼顯示scrollView,但我想要顯示的圖像(教程)比視圖大。換句話說,tutorial.png正好是280X1200,但它不會使用aspectFit。我想的東西這裏小:UIScrollView與大圖

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

回答

2

請看下面編輯code.It將工作

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