2012-10-04 3 views
0

이것은 달성하고자하는 것입니다.UIScrollview 내부에 뷰 배치하기

|------------------------------------------------------| 
|      view 1 here      | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|      view 2 here     | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|     view 3 here      | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
|              | 
| -----------------------------------------------------| 

3 개의보기가있는 scrollview가 있어야합니다. 나는 다음을하고있다.

-(void)viewDidLoad 
{ 
    keeperView = [[UIView alloc] init]; 
    aanvallerView = [[UIView alloc] init]; 
    middenvelderView = [[UIView alloc] init]; 
    listView.contentSize=CGSizeMake(1280,2360); 
    [listView addSubview:keeperView]; 
    [listView addSubview:aanvallerView]; 
    [listView addSubview:middenvelderView]; 
} 

그러나보기 하나만 보여줍니다. 문제가 무엇인지 아는 사람이 있습니까?

친절에 감사드립니다.

답변

2

에 viewDidLoadMethod에서 :

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
[scrollView setContentSize:CGSizeMake(320, 1100)]; 
[scrollView setScrollEnabled:YES]; 
[self.view addSubview:scrollView]; 

UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 320, 300)]; 
[view1 setBackgroundColor:[UIColor redColor]]; 
[scrollView addSubview:view1]; 

UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 400, 320, 300)]; 
[view2 setBackgroundColor:[UIColor blueColor]]; 
[scrollView addSubview:view2]; 

UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(0, 750, 320, 300)]; 
[view3 setBackgroundColor:[UIColor yellowColor]]; 
[scrollView addSubview:view3]; 

결과 :

Different View

Different views 2

Different Views 3

모든 3 개의보기가 Scrollview에 있습니다! 당신도있는 ScrollView ^^

+0

올바른 해결책! – Steaphann

4

프레임이없는 것일 수 있습니다. initWithFrame 전화하십시오 UIViews

+0

또 다른있는 ScrollView는 몇 가지 코드를 제공 할 수있다 만들 수) :

를 addSubview를 사용함으로써, 당신은 지금 당신의 의견에 원하는 모든 것을 넣을 수 있습니다? – Steaphann

관련 문제