Ipad 在XIB之间滑动

Ipad 在XIB之间滑动,ipad,Ipad,我使用按钮在XIB之间切换。我的功能是这样的: -(IBAction)swapViews; { SecondViewController *second2 =[[SecondViewController alloc initWithNibName:@"SecondViewController" bundle:nil]; second2.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

我使用按钮在XIB之间切换。我的功能是这样的:

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

如何在XIB之间使用滑动?

要在两个视图之间滑动,不应以模式显示它们(
presentModalViewController

请看一下
[UIScrollView][1]
,并查看以下内容

简而言之,您应该创建您的
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];

}

为了能够在两个视图之间滑动,您不应该以模式显示它们(
presentModalViewController

请看一下
[UIScrollView][1]
,并查看以下内容

简而言之,您应该创建您的
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];

}

没问题。看看我的编辑。。。我正在加载两个XIB并将它们放置在滚动视图中。。。这对你有意义吗?没问题。看看我的编辑。。。我正在加载两个XIB并将它们放置在滚动视图中。。。这对你有意义吗?