UIScrollView 添加 UIViewController 作为子视图?使用 UIPageControl [英] UIScrollView adding UIViewController as a sub view? with UIPageControl

查看:25
本文介绍了UIScrollView 添加 UIViewController 作为子视图?使用 UIPageControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发我的应用程序,并希望拥有一个 UIScrollView 和 UIPageControl,这将允许用户向左和向右滑动屏幕以访问不同的视图控制器.

I am currently working on my application and would like to have a UIScrollView and UIPageControl which would allow the user to swipe the screen left and right to get to different view controllers.

到目前为止我有这个工作,所以我可以向左和向右滑动以查看任何一个视图控制器,但是我发现当我的一个 UIViewControllers 需要访问它时委托什么都不发生,例如 UITableViewDelegate.

I have this working so far, so that I can swipe left and right to see either view controller however I am finding that when one of my UIViewControllers needs to access it delegate nothing happens, for example UITableViewDelegate.

这是我目前在 scrollViewController 中的代码

This is the code i have so far in my scrollViewController

 CGRect frame2;
frame2.origin.x = self.scrollView.frame.size.width * 1;
frame2.origin.y =30;
frame2.size = self.scrollView.frame.size;
myViewController *vc3 = [[myViewController alloc] initWithNibName:@"myViewController" bundle:nil];
vc3.view.frame = frame2; 

[self.scrollView addSubview:vc3.view]; 
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * 2, self.scrollView.frame.size.height);

我不能做的一件事也是发布 [vc3 发布];将其添加到 scrollView 后,应用程序将崩溃.

One thing I am not able to do also is release [vc3 release]; after adding it to the scrollView the app will just crash.

任何帮助都会很棒,如果我以错误的方式处理此问题,也请告诉我.

Any help would be great, also please let me know if I am going about this the wrong way.

谢谢亚伦

推荐答案

通过添加 v3.view ,v3 的保留计数不会增加.所以你不能发布 v3.你可以
[v3.view release];

By adding v3.view , v3's retain count wont increase. So you cant release v3. you can
[v3.view release];

这篇关于UIScrollView 添加 UIViewController 作为子视图?使用 UIPageControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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