turkenh
turkenh

Reputation: 2584

Dynamically setting size of frame of a UITableView which is placed in UIScrollView

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

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(width: 3500, height: scrollView.contentSize.height)

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.

Need to change this from code

Upvotes: 0

Views: 1737

Answers (2)

Jo Albright
Jo Albright

Reputation: 570

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

https://github.com/joalbright/Excel

Upvotes: 1

Fabio Felici
Fabio Felici

Reputation: 2916

Apple Documentation discourages you from embedding UITableView inside UIScrollView.

You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

Anyway are your UITableView and UIScrollView scrolling horizontally?

Upvotes: 0

Related Questions