动态设置放置在UIScrollView中的UITableView的框架大小 [英] Dynamically setting size of frame of a UITableView which is placed in UIScrollView

查看:63
本文介绍了动态设置放置在UIScrollView中的UITableView的框架大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用swift,并且有一个故事板,其中包含一个UIViewController,其中包括一个带有UITableView的UIScrollView.

I am using swift and have a story board containing a UIViewController which includes a UIScrollView with UITableView.

我想做的是将Excel文件加载到表中,因此我需要水平滚动.我可以使用以下方法设置滚动视图的内容大小:

What am I trying to do is to load an excel file in a table so I need to scroll horizontally. I can set the content size of scroll view with:

scrollView.contentSize = CGSize(宽度:3500,高度:scrollView.contentSize.height)

scrollView.contentSize = CGSize(width: 3500, height: scrollView.contentSize.height)

我还需要设置UITableView的框架大小.当我从情节提要中设置显示的字段时,它可以工作,但是当我从viewDidLoad方法中以编程方式设置它时,则不起作用.宽度值显示为更改为3500,但是当我在tableView cellForRowAtIndexPath方法中签入时,我看到了故事板上设置的值.

I do also need to set the size of frame of UITableView. When I set it from storyboard with the field shown it works, but when I set it programmatically from viewDidLoad method it does not work. The width value is shown as changed to 3500 but when I checked in tableView cellForRowAtIndexPath method, I see the value set in story board.

推荐答案

这是我刚刚创建的示例项目,以查看是否可以创建您要的内容.

Here is a sample project I just created to see if I could create what you are asking for.

https://github.com/joalbright/Excel

这篇关于动态设置放置在UIScrollView中的UITableView的框架大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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