2013-03-15 3 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]; 
Смежные вопросы