带有多个UIViewControllers的UIScrollView [英] UIScrollView with multiple UIViewControllers

查看:114
本文介绍了带有多个UIViewControllers的UIScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有xib文件的scrollview和4个UIviewcontrollers现在我想将4个viewcontrollers添加到scrollview

i have one scrollview and 4 UIviewcontrollers with xib files now i want to add 4 viewcontrollers to scrollview

并且还为四个viewcontrollers启用了滚动

and also the scroll is enabled for four viewcontrollers

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

any one know this plz answer this problem

推荐答案

只需添加它们即可。有什么问题?

Just add them. What's the problem?

// 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];

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

Do this for all your four controllers.

这篇关于带有多个UIViewControllers的UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆