Tuesday, June 30, 2026
HomeiOS Developmentios - Xcode 11 - dynamic tableview top

ios – Xcode 11 – dynamic tableview top

[ad_1]

i’ve a little bit drawback in my iOS-app and hope somebody can assist.
Each resolution and / or hints are welcome.

First my workaround:
Xcode 11.3.1 and Swift 5

I’ve a ScrollView that’s autolayouted by constraints 0, 0, 0, 0.
On this Scrollview I’ve some ImageViews, Labels .. in StackViews.
Additionally in a StackView I’ve a TableView with a customized cell-class for reuse.
The cell top is about to computerized and the VC has this code:
tableView.estimatedRowHeight = 70

Within the cell is a Label – that is set textlabel.numberOfLines = 0 to have a dynamic top and present at all times the whole textual content.

Now my situation:
The peak of the tableView does not match with the peak of the scrollView. That is regular I believe 🙂 as a result of the tableView do not know the peak of every cell.
Result’s – consumer scrolls the scrollView after which the tableView.

After I swap to static top for cells i.e. to 70px I can multiply the rely of cells with the static top of the cell. That works! My code in VC is:
@IBOutlet weak var tableViewHeight: NSLayoutConstraint!

and within the extension of tableViewDataSource (numberOfRowsInSection)
let rows = feedback.rely
tableViewHeight.fixed = CGFloat(rows * 70)

How can I get the tableView to appropriate top dynamically that the tableView is NOT scrollable and scrolling the scrollView does that?

Thanks for consideration,
type regards,
Steven

PS: feedback is an array after all 😉

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments