的UIScrollView多UIViewControllers
问题描述:
我有厦门国际银行文件,一个滚动型和4 UIviewcontrollers现在我想加4个viewcontrollers以滚动型的UIScrollView多UIViewControllers
,也是滚动四个viewcontrollers
任何一个启用知道这PLZ回答问题
答
只需添加它们即可。有什么问题?
// 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];
对所有的四个控制器都这样做。
答
是的,你可以添加viewcontrollers的意见,你的滚动视图,但要记住,你正在自己等同于一个的UITabBarController或UINavigationController的,所以你有一定的责任:
当你的alloc初始化你vc从一个nib vc将得到其调用的viewDidLoad方法。
但是,当你把vc.view放到你的滚动视图中时,你需要调用[vc viewDidAppear:YES](并且如果你的vc使用它,也调用viewWillAppear)。
请注意诸如从vc展示模态视图控制器的事情,因为这可能无法按预期工作。
彼得
感谢ü这个 – user564963 2011-02-12 11:20:32
但滚动未启用四个viewcontrollers PLZ告诉我如何处理四个viewcontrollers在这个滚动属性 – user564963 2011-02-12 11:21:15