2011-08-09 4 views
0

버튼을 사용하여 XIB간에 전환합니다. 내 기능은 다음과 같습니다.XIB간에 스 와이프

-(IBAction)swapViews; { 
    SecondViewController *second2 =[[SecondViewController alloc 
     initWithNibName:@"SecondViewController" bundle:nil]; 
    second2.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
    [self presentModalViewController:second2 animated:YES]; 
    [second2 release]; 
} 

XIB에서 어떻게 쓸 수 있습니까?

답변

3

두보기간에 스 와이프 할 수 있도록하려면 모달로 표시하면 안됩니다 (presentModalViewController).

[UIScrollView][1] 및이 simple tutorial에서 살펴보십시오.

즉, UIScrollView을 만들어서 스 와이프를 관리 한 다음 스 와이프하여 관리하려는 모든보기를 하위보기로 UIScrollView으로 추가해야합니다.

- (void)loadView { 
    [super loadView]; 
    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0,  self.view.frame.size.width, self.view.frame.size.height)]; 
    scroll.pagingEnabled = YES; 

    FirstViewController *first =[[FirstViewController alloc initWithNibName:@"FirstViewController" bundle:nil]; 
    [scroll addSubview:first.view]; 

    SecondViewController *second =[[SecondViewController alloc initWithNibName:@"SecondViewController" bundle:nil]; 
    [scroll addSubview:second.view]; 

    scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height); 
    [self.view addSubview:scroll]; 
    [scroll release]; 

}

+0

하지만 난 같은 XIB –

+0

아무런 문제가 많은 XIB 많은되지 볼 수 있습니다. 내 편집 좀 봐 ... 두 xibs를로드하고 스크롤보기에 배치 ... 당신에게 이해가 되니? – sergio

+0

예 thx brooooo –

관련 문제