带有多个UIViewControllers的UIScrollView

use*_*963 2 iphone sdk

我有一个scrollview和4个UIview控制器与xib文件现在我想添加4个viewcontrollers到scrollview

并且还为四个视图控制器启用了滚动

任何人都知道这个PLZ回答这个问题

pt2*_*ph8 9

只需添加它们.有什么问题?

// this loads a view controller from a nib
controller = [[UIViewController alloc] initWithNibName:@"YourNibsName" bundle:nil];

// this adds the viewcontroller's view to the scrollview
[scrollView addSubview:controller.view];

// place the subview somewhere in the scrollview
CGRect frame = controller.view.frame;
frame.origin.x = 600;
controller.view.frame = frame;

// don't forget to release the viewcontroller somewhere in your dealloc
[controller release];
Run Code Online (Sandbox Code Playgroud)

为所有四个控制器执行此操作.