简体   繁体   English

有多个UITableViews的UIScrollView? 如何最好地进行设置?

[英]UIScrollView with multiple UITableViews? How best to set this up?

自定义AccountViewController NIB

So the above is a screenshot from IB of my custom UIViewController. 因此,以上是我的自定义UIViewController的IB屏幕快照。 This main view contains lots of information. 此主视图包含许多信息。 The ImageViews are temporary placeholders just for information / buttons to help me get an idea for my layout. ImageViews是临时占位符,仅用于信息/按钮,以帮助我了解布局。

You'll see at the bottom I have dumped a UIScrollView. 您会在底部看到我已经转储了UIScrollView。 What I want to do is dump 3 UIView's inside the ScrollView, where each UIView contains a UITableView. 我想做的是在ScrollView中转储3个UIView,其中每个UIView都包含一个UITableView。 This NIB/XIB file though is getting very cluttered and messy. 但是,此NIB / XIB文件变得非常混乱和混乱。 I would like to create a new NIB which loads inside the UIScrollView. 我想创建一个新的NIB,将其加载到UIScrollView中。 What's the best way to go about doing this? 这样做的最佳方法是什么?

Do I dump a new UIViewController into this XIB file, and then make the delegate of ScrollView the new ViewController ? 我是否将新的UIViewController转储到此​​XIB文件中,然后使ScrollView的委托成为新的ViewController? then I can just set a custom nib for that UIViewController? 那么我可以为该UIViewController设置一个自定义笔尖? Is that the proper way to do this? 这是正确的方法吗?

Still coming to grips with Interface Builder and more advanced app. 仍然可以使用Interface Builder和更高级的应用程序。 development! 发展!

Thanks in advance! 提前致谢!

When dealing with Scroll Views and the content inside of them, this is what I usually do... 当处理滚动视图及其中的内容时,这通常是我要做的...

I put the scroll view in my main view and create an IBOutlet in my view controller that is connected to it. 我将滚动视图放在主视图中,并在与其连接的视图控制器中创建一个IBOutlet。

Then I create a second UIView in the xib that is my Content View (contentsOfScrollView) and create an IBOutlet in my view controller that is connected to it. 然后,在xib中创建第二个UIView,即我的内容视图(contentsOfScrollView),并在与其连接的视图控制器中创建一个IBOutlet。

Then in my viewDidLoad I programmatically put the content view into the scroll view, like so: 然后在我的viewDidLoad中,以编程方式将内容视图放入滚动视图,如下所示:

[self.scrollView addSubview:self.contentsOfScrollView];
self.scrollView.contentSize = self.contentsOfScrollView.frame.size;

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM