UIScrollView and x,y coordinates problem

Hi, I’m having difficulty solving an issue with scrollview. I’m presenting a modal view programatically. I have a tableview inside a scrollview. It pinch zooms nicely, magnifying the content if needed, but the content disappears off to the right and bottom. It cannot be panned to the left and upwards to bring the content back into view. Basically the views x,y edges are fixed at 0 I guess. I’ve tried all kinds of changes and googled but so far without success.

Here’s my code. The viewcontroller does have scrollviewdelegate set:

let scrollView = UIScrollView()

@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var toolBar: ToolBarView!

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    
    scrollView.delegate = self
    scrollView.minimumZoomScale = 1.0
    scrollView.maximumZoomScale = 3.0
    scrollView.zoomScale = 1.0
    let frame = self.view.bounds
    scrollView.frame = frame
    self.view.addSubview(scrollView)
    scrollView.addSubview(tableView)
    self.view.bringSubviewToFront(toolBar)

You shouldn’t do this, for this reason that you have 2 scroll views that conflict.

UITableView inherits from UIScrollView

Does this table view have to be inside another scroll view?

I only put it inside the scrollview because I thought it was the way to make it pinch zoomable, otherwise there’s no other reason to place it in there. Is it possible to make a tableview pinch zoomable and pannable? As I said, it is pinch zooming.

Not for a table view, but a collection view could

You’re wanting to have like a table that you can zoom around and pinch to see more or less data right?

Yes, that’s what I was aiming for. Not so much to see more or less data. I want it zoomable for anyone who might need to see the info more clearly. I have switched over to using a label and formatting it as attributed text. It works well, but it would still be interesting to achieve it with a tableview. There didn’t seem to be a conflict with the tableview inside the scrollview. The table still worked as it should and it was zoomable. Perhaps the fixed edges was due to a conflict.

What does the data look like? Because I’m confused what zooming in achieves, if not to see more / less data

Like I’m thinking how google sheets works

Maybe not right now, but generally you don’t put multiple scroll views together like that, see the human interface guidelines

Yes if you are going to do this, you have to constrain everything properly. Any element should always somehow have an x,y position (where it’s located) and height, width (it’s size)

It’s basically a column of letters, a column of numbers and a column of symbols. I want the zoom, not to see more or less data, but to magnify for anyone who wants to be certain of what they’re seeing. I went with the tableview because it seemed the easiest way to present the data. I have put it all into an attributedString now and placed it in a label inside a scrollview. It works well and pinch/zooms they way I want.